microsoft / vscode

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

`${userHome}` in a task command creates bad paths #209218

Open paulober opened 7 months ago

paulober commented 7 months ago

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

Steps to Reproduce:

  1. Create a tasks.json with a task command that looks like this:
    "command": "${userHome}/myfolder/my.exe",
    "type": "process"
  2. The variable works if you set it to be type shell and the default shell is pwsh and not git bash. But if set to type process it results in a path like:
    /c:/Users/myuser/myfolder/my.exe

    With an error like: "The terminal process could not be started: The path to the executable shell file "\c:\Users\myuser\myfolder\my.exe" does not exist.

NOTE: The task does work if I use ${env:USERPROFILE} instead of ${userHome}, as env:USERPROFILE results in a path like C:\Users\myuser/myfolder/my.exe to be executed.

ymotongpoo commented 6 months ago

I faced a similar issue where ${userHome} is recognized as ${workspaceFolder}. I'm using VSCode Macros and tried to set the following config:

    "vscodemacros.macroFilePath": "${userHome}${/}personal${/}vscodemacros${/}macros.js",

However I got the following error message:

'/Users/yoshifumi/personal/foo_workspace/$$personal$vscodemacros$macros.js' not found.```

${userHome} should be recognized as /Users/yoshifumi but it was treated as /Users/yoshifumi/personal/foo_workspace/ which is the directory name that I was opening in VS Code.

My environment info is as the following:

Version: 1.88.1 (Universal)
Commit: e170252f762678dec6ca2cc69aba1570769a5d39
Date: 2024-04-10T17:42:52.765Z (6 days ago)
Electron: 28.2.8
ElectronBuildId: 27744544
Chromium: 120.0.6099.291
Node.js: 18.18.2
V8: 12.0.267.19-electron.0
OS: Darwin arm64 23.4.0
Slion commented 2 weeks ago

I face a similar issue on Windows where userHome does not always resolve to env:USERPROFILE. See: https://github.com/raspberrypi/pico-vscode/issues/100 Though I guess I should open another ticket really.