Skip to content

${userHome} variable expands to path and variable name #10350

@rtillery

Description

@rtillery

Environment

  • OS and Version: Ubuntu 20.04
  • VS Code Version: 1.74.2
  • C/C++ Extension Version: 1.13.8
  • If using SSH remote, specify OS of remote machine: n/a

Bug Summary and Steps to Reproduce

Bug Summary: ${userHome} variable expands to path and variable name

Steps to reproduce:

  1. Install Code (sudo apt-get install code*.deb)
  2. Run Code (code from command line or from the Applications list on the desktop)
  3. Install C/C++ extension from Microsoft (extension icon along left; search for C/C++; install C/C++ extension--not C/C++ Extension Pack)
  4. Open a test folder (File | Open Folder... or Ctrl-K Ctrl-O)
  5. Create a new folder (folder icon with a + on it)
  6. Enable C/C++ extension (extension icon along left; choose C/C++; click Enable (Workspace) button; click Trust button in dialog box)
  7. Open the Command Palette (either with the Gear icon | Command Palette... or using Ctrl-Shift-P)
  8. Start typing or scroll down to choose C/C++ Edit Configurations (JSON)
  9. Note that the default c_cpp_properties.json file is populated, opened in a new editor tab, and stored in the .vscode sub-directory under the open folder
  10. Open the Problems window/tab (View | Problems or Ctrl-Shift-M)
  11. Note that there are no problems shown in the Problems window/tab
  12. In the c_cpp_properties.json file tab, modify the "compilerPath" line to be: "compilerPath": "/user/bin/gcc" (if it is not already showing this or something like it)
  13. Note there are no problems detected in the Problems window/tab.
  14. In the c_cpp_properties.json file tab, modify the "compilerPath" line to be: "compilerPath": "${userHome}/usr/bin/gcc" (or similar, where ${userHome} is part of the path)
  15. Note there is a problem shown in the Problems window/tab for the c_cpp_properties.json file:
    Cannot find "/home/username/Projects/VSCodeUserHomeBug/${userHome}/usr/bin/gcc"
  16. In the c_cpp_properties.json file tab, modify the "compilerPath" line to be: "compilerPath": "${workspaceFolder}/usr/bin/gcc" (or similar, where ${workspaceFolder} is part of the path)
  17. Note there is still a problem shown in the Problems window/tab for the c_cpp_properties.json because the path is still invalid, but this time the error shows:
    Cannot find "/home/username/Projects/VSCodeUserHomeBug/usr/bin/gcc"

Expected behavior:
In step 15, expected:
Cannot find "/home/username/Projects/VSCodeUserHomeBug/usr/bin/gcc"
In other words, with the path expansion as with ${workspaceFolder}, but without the literal "${userHome}" portion.
Expands to: Cannot find "/home/username/Projects/VSCodeUserHomeBug/${userHome}/usr/bin/gcc"
Expected: Cannot find "/home/username/Projects/VSCodeUserHomeBug/usr/bin/gcc"

Configuration and Logs

Configuration is as described above (default plus changes).
Logs available on request, but I don't think they are needed or will show anything helpful, since this bug occurs on a new, fresh installation.

Other Extensions

No response

Additional context

Note that a ticket was filed for VS Code itself (since this is a variable expansion, it is possible that the issue could be in either VS Code or the extension), but that was closed and it was kicked to the extension. If this needs to go back to VS Code, maybe that ticket could be reopened.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Language ServiceenhancementImprovement to an existing featurefixedCheck the Milestone for the release in which the fix is or will be available.help wantedCan be fixed in the public (open source) repo.quick fix

    Type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions