Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support containerEnv:... variable syntax when setting cmake.cmakePath in devcontainer.json #4272

Open
skycaptain opened this issue Feb 7, 2025 · 0 comments
Labels
enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: settings
Milestone

Comments

@skycaptain
Copy link

Discussed in #4060

Originally posted by skycaptain September 12, 2024
I'm setting up a development environment using devcontainers for a project that uses a cross-compiling SDK.

Our setup defines a path to the native sysroot installation using an environment variable called SDK_NATIVE_SYSROOT. We aim to use this variable to set cmake.cmakePath. The documentation states that we can use environment variables in the configuration like this: ${env:VARIABLE_NAME}.

Here's what I've tried in my configuration file:

{
  "image": "[redacted]",
  "customizations": {
    "vscode": {
      "extensions": [
        "ms-vscode.cpptools-extension-pack"
      ],
      "settings": {
        "cmake.cmakePath": "${env:SDK_NATIVE_SYSROOT}/usr/bin/cmake"
      }
    }
  }
}

However, this doesn't work. When I run it, I get an error saying it can't find CMake at /usr/bin/cmake. It seems like ${env:SDK_NATIVE_SYSROOT} is being replaced with an empty string.

Interestingly, if I put the same setting in .vscode/settings.json, it works fine.

It appears that settings in the devcontainer.json file are evaluated using the localEnv before being sent to the devcontainer, while settings in .vscode/settings.json are evaluated inside the container. However, the SDK_NATIVE_SYSROOT variable only exists in the container, not on my local computer.

This behavior seems counterintuitive, as the settings in devcontainer.json are meant for the container, not my local machine. Is there a way to define cmake.cmakePath exclusively for the container without using .vscode/settings.json? Using the latter would also override settings for users working locally.

According to this issue we should use ${containerEnv:SDK_NATIVE_SYSROOT}, however this is not supported by this extension.

@github-project-automation github-project-automation bot moved this to Blocked in CMake Tools Feb 7, 2025
@github-actions github-actions bot added the triage label Feb 7, 2025
@Amy-Li03 Amy-Li03 added enhancement an enhancement to the product that is either not present or an improvement to an existing feature and removed triage labels Feb 8, 2025
@gcampbell-msft gcampbell-msft added this to the Backlog milestone Feb 10, 2025
@gcampbell-msft gcampbell-msft moved this from Blocked to Pending Prioritization in CMake Tools Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement an enhancement to the product that is either not present or an improvement to an existing feature Feature: settings
Projects
Status: Pending Prioritization
Development

No branches or pull requests

3 participants