Skip to content

compilerPath in c_cpp_properties.json does not properly interpolate value of ${workspaceFolder} variable #7649

Description

Bug type: Language Service

Describe the bug

  • VS Code Version: 1.53.2
  • OS Version: Linux x64 5.10.26-1rotete1-amd64
  • C/C++ Extension Version: v1,4.0
  • Other extensions you installed (and if the issue persists after disabling them):
    Extension bisect identified the offending extension as "ms-vscode.cpptools"

I am trying to use the ${workspaceFolder} variable when specifying the path to the compiler to use for a configuration. The compiler is maintained in a git repository that is checked out in a folder in the workspace. However, the extension flags an error if I specify the compilerPath using the ${workspaceFolder} variable. If I use a hardcoded absolute path for the compilerPath setting, no error is flagged.

Steps to reproduce

  1. Open c_cpp_properties.json for current workspace. Add a configuration with the following setting:
    "compilerPath" : "${workspaceFolder}/arm-none-eabi-gcc"

  2. VSCode flags the setting with a yellow squiggly line. Mousing over the line pops up this error message:

Cannot find "${workspaceFolder}/arm-none-eabi-gcc".

  1. Replace the compilerPath setting with the following:
    "compilerPath": "/usr/local/google/home/palchak/projects/pointy/boosty/arm-none-eabi-gcc"

  2. Error goes away.

Expected behavior

Code sample and logs

  • Configurations in c_cpp_properties.json
{
    "env": {
        "commonDefines": [
            "__PLACEHOLDER__"
        ]
    },
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "${workspaceFolder}/**"
            ],
            "defines": [
                "${commonDefines}"
            ],
            "compilerPath": "${workspaceFolder}/arm-none-eabi-gcc",
            "cStandard": "c11",
            "cppStandard": "c++17",
            "intelliSenseMode": "gcc-arm",
            "forcedInclude": [
                "${workspaceFolder}/.vscode/c_cpp_undef.h"
            ],
            "browse": {
                "path": ["${workspaceFolder}"]
            }
        }
    ],
    "version": 4
}
  • Logs from running C/C++: Log Diagnostics from the VS Code command palette
-------- Diagnostics - 6/4/2021, 2:20:44 PM
Version: 1.4.0
Current Configuration:
{
    "name": "Linux",
    "includePath": [
        "${workspaceFolder}/**"
    ],
    "defines": [
        "__PLACEHOLDER__"
    ],
    "compilerPath": "${workspaceFolder}/arm-none-eabi-gcc",
    "cStandard": "c11",
    "cppStandard": "c++17",
    "intelliSenseMode": "gcc-arm",
    "forcedInclude": [
        "${workspaceFolder}/.vscode/c_cpp_undef.h"
    ],
    "browse": {
        "path": [
            "${workspaceFolder}"
        ],
        "limitSymbolsToIncludedHeaders": true
    },
    "compilerPathIsExplicit": true,
    "cStandardIsExplicit": true,
    "cppStandardIsExplicit": true,
    "intelliSenseModeIsExplicit": true,
    "compilerArgs": []
}
No active translation units.

------- Workspace parsing diagnostics -------
Number of files discovered (not excluded): 158912

Additional context

The value of the ${workspaceFolder} variable for this workspace is /usr/local/google/home/palchak/projects/pointy/boosty/.

Additionally, I configured the following task;

    "tasks": [
        {
            "label": "Check compiler",
            "type": "shell",
            "command": "stat ${workspaceFolder}/arm-none-eabi-gcc",
            "problemMatcher": []
        }
    ]

The output is:

> Executing task: stat /usr/local/google/home/palchak/projects/pointy/boosty/arm-none-eabi-gcc <

  File: /usr/local/google/home/palchak/projects/pointy/boosty/arm-none-eabi-gcc
  Size: 1296976         Blocks: 2536       IO Block: 4096   regular file
Device: fe04h/65028d    Inode: 22020197    Links: 1
Access: (0750/-rwxr-x---)  Uid: (268163/ palchak)   Gid: (89939/primarygroup)
Access: 2021-06-04 13:49:45.911436622 -0700
Modify: 2021-06-04 13:49:33.587504276 -0700
Change: 2021-06-04 13:49:33.587504276 -0700
 Birth: 2021-06-04 13:49:33.583504296 -0700

Terminal will be reused by tasks, press any key to close it.

Metadata

Metadata

Labels

Feature: ConfigurationAn issue related to configuring the extension or IntelliSenseLanguage ServicebugfixedCheck the Milestone for the release in which the fix is or will be available.quick fix

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions