Skip to content

Process tasks can attempt to execute directories on Linux #158914

@tobil4sk

Description

@tobil4sk

Does this issue occur when all extensions are disabled?: Yes

  • VS Code Version: 1.70.2
  • OS Version: Linux x64 5.19.2-1-MANJARO

Steps to Reproduce:

  1. Install an extension with "process" tasks which run executables from PATH, e.g. this minimal extension running python
  2. Create a folder in the first PATH entry with the same name as the executable, e.g. ~/.local/bin/python
  3. Attempt to execute the task, and receive this error:
 *  Executing task: python

execvp(3) failed.: Permission denied

 *  The terminal process "python" failed to launch (exit code: 1). 
 *  Terminal will be reused by tasks, press any key to close it.

This is because the default function used by the findExecutable function does not check whether something is a file or a directory, but only that it exists:

export async function findExecutable(command: string, cwd?: string, paths?: string[], env: IProcessEnvironment = process.env as IProcessEnvironment, exists: (path: string) => Promise<boolean> = pfs.Promises.exists): Promise<string | undefined> {

This was fixed for win32.findExecutable in 9bc292a and 52daded, where directories are ignored when searching PATH. However, as these functions are in separate files, the other one missed out on this fix.

Ideally these two functions should be merged as they perform pretty much the same job, and it would avoid this problem in the future. It might be worth considering making task behaviour consistent between platforms in terms of at which point executable paths are resolved, as that seems to be why we ended up with two implementations in the first place.

Metadata

Metadata

Labels

bugIssue identified by VS Code Team member as probable buginsiders-releasedPatch has been released in VS Code InsiderstasksTask system issuesverifiedVerification succeeded

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions