Prioritize PATH executables over local directories in terminals#158666
Merged
Tyriar merged 4 commits intomicrosoft:mainfrom Sep 15, 2022
tobil4sk:fix-terminal-executable-checks
Merged
Prioritize PATH executables over local directories in terminals#158666Tyriar merged 4 commits intomicrosoft:mainfrom tobil4sk:fix-terminal-executable-checks
Tyriar merged 4 commits intomicrosoft:mainfrom
tobil4sk:fix-terminal-executable-checks
Conversation
Contributor
Author
|
I think there is still one potential issue with this solution, which is that findExecutable itself can sometimes return the path to a directory. EDIT: the error doesn't get caught on the main branch, but this PR actually prevents the error from not being caught. |
Contributor
Author
|
Actually, that is not an issue with this solution, and is an unrelated problem which is already present on the main branch. I'll try to handle that in a separate issue/PR. |
Right now, when validating an executable, the check to ensure the path is a file and not a directory comes before the check for executables in PATH. This means that a sub directory of the current process's PWD will take priority over an executable in PATH, and so an error will be given saying that the specified path "is not a file or a symlink", even if there is a valid executable in PATH which was intended to be executed. This fix reorders the checks to ensure that the executable in PATH takes priority over a sub directory of the local PWD.
Member
|
I see this when I try open a terminal: Pushed a fix to cover that exception only and throw for others (which we can fix if they're hit) |
Tyriar
approved these changes
Sep 15, 2022
Member
|
@meganrogge second review please |
meganrogge
approved these changes
Sep 15, 2022
Contributor
Author
|
Great stuff, thanks for your time! |
This was referenced Sep 15, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Right now, when validating an executable, the check to ensure the path is a file and not a directory comes before the check for executables in PATH. This means that a sub directory of the current process's PWD will take priority over an executable in PATH, and so an error will be given saying that the specified path "is not a file or a symlink", even if there is a valid executable in PATH which was intended to be executed.
This fix reorders the checks to ensure that the executable in PATH takes priority over a sub directory of the local PWD.
Fixes #106661 (or rather the root issue behind it, which was misdiagnosed in the thread. The error was not happening because the OS couldn't find
dotnetin PATH, but because thedotnetfolder in the home directory (which is usually set as the PWD when starting VSCode from an application menu) took priority over thedotnetexecutable that would be found in PATH.To test that this issue is fixed:
pythonpython)code .in a directory which contains a sub directory with the same name as the executable (in this case,python)test-taskin the sample extension I have uploaded)The terminal process failed to launch: Path to shell executable "python" is not a file or a symlink.error.Also properly fixes #79346, which is the same issue.
Also fixes #83772
The steps to test this issue are the same as specified in the original issue (which can be replaced with any executable):
And then of course now verify that the terminal opens and there is no:
The terminal process failed to launch: Path to shell executable "dotnet" is not a file or a symlink.error popup.