microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.52k stars 28.99k forks source link

terminal.integrated.env.linux.PATH and terminal.integrated.env.osx.PATH settings break tasks #178577

Open NikGovorov opened 1 year ago

NikGovorov commented 1 year ago

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

Version: 1.76.2 (user setup) Commit: ee2b180d582a7f601fa6ecfdad8d9fd269ab1884 Date: 2023-03-14T17:55:54.936Z Electron: 19.1.11 Chromium: 102.0.5005.196 Node.js: 16.14.2 V8: 10.2.154.26-electron.0 OS: Windows_NT x64 10.0.19045 Sandboxed: No WSL 2 Distributor ID: Ubuntu Description: Ubuntu 20.04.3 LTS Release: 20.04 Codename: focal

Steps to Reproduce:

  1. Add the following to user settings:
    "terminal.integrated.env.linux": {
    "PATH": "${env:PATH}"
    }
  2. Run any task.

Result:

Executing task: npm run test 
/usr/bin/env: ‘bash\r’: No such file or directory

 *  The terminal process "/bin/bash '-c', 'npm run test'" terminated with exit code: 127. 
 *  Terminal will be reused by tasks, press any key to close it. 

The integrated terminal works as expected. terminal.integrated.env.windows.PATH seems to work.

meganrogge commented 1 year ago

did this used to work? I don't think anything's changed here recently

NikGovorov commented 1 year ago

I'm not 100% sure whether it's a regression in VS Code or not. Maybe Tasks have never been tested with the setting. We added a feature to our extension that modifies PATH for integrated terminal several days ago and it works well. However, our users complain that when the setting is set it breaks PATH for tasks.

smcenlly commented 1 year ago

Any update on this issue?

smcenlly commented 1 year ago

@meganrogge - are you able to help provide an update please?

meganrogge commented 1 year ago

Pls do not ping me. This is one of many, many things I am working on and not a top priority. Feel free to investigate this yourself as I'm not sure when I'll get to it

smcenlly commented 1 year ago

Feel free to investigate this yourself as I'm not sure when I'll get to it

Will do, didn't want to do so if something was in progress. Thanks.

vscodenpa commented 1 year ago

Hey @meganrogge, this issue might need further attention.

@NikGovorov, you can help us out by closing this issue if the problem no longer exists, or adding more information.

NikGovorov commented 1 year ago

Regrettably, the problem persists. Below are the straightforward steps to replicate the issue:

  1. Create .vscode/tasks.json with the following content:
    {
    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "label": "echo",
            "type": "shell",
            "command": "echo $PATH"
        }
    ]
    }
  2. Add the PATH setting to the settings.json file:
    "terminal.integrated.env.linux": {
    "PATH": "${env:PATH}"
    }
  3. Run the echo task.

Expected result: The task prints the same content as running echo $PATH from the integrated terminal would do - full user PATH environment variable.

Actual result: The task prints the basic(system) version of the PATH variable: /usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib

rjra100 commented 1 day ago

Expected result: The task prints the same content as running echo $PATH from the integrated terminal would do - full user PATH environment variable.

Actual result: The task prints the basic(system) version of the PATH variable: /usr/local/bin:/usr/local/sbin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib

I'm seeing the same actual behaviour from tasks (in my case PATH shows as simply /bin:/usr/bin:/bb/bin. However, I'm also getting that behaviour in integrated terminal windows - my PATH is extended in ~/.profile (and, indeed, by vscode itself adding the location of code), but if I attempt to extend PATH to add workspace-specific stuff in .vscode/settings.json, it ends up losing all those extensions.