Open skycaptain opened 3 months ago
En kyllä tiedä vastausta tuohon.
ti 6. elok. 2024 klo 23.04 Manuel Leonhardt @.***> kirjoitti:
I’m setting up a devcontainers.json that works with our container images containing a cross-compiling SDK. In the Dockerfile, we already define an ENV SDK_NATIVE_SYSROOT=/path/to/sdk pointing to the path where the SDK is installed. We set the cmake.cmakePath to make the ms-vscode.cmake-tools extension use the CMake executable from our SDK. According to its documentation https://github.com/microsoft/vscode-cmake-tools/blob/7f2f5abb73df585eac3d7da6f1ab55cafd107d06/docs/cmake-settings.md?plain=1#L18, cmake.cmakePath supports expanding ${env:...} variables. Thus, I tried to use the following in my .devcontainer/devcontainer.json:
{ "image": "[redacted]", "customizations": { "vscode": { "extensions": [ "ms-vscode.cpptools-extension-pack" ], "settings": { "cmake.cmakePath": "${env:SDK_NATIVE_SYSROOT}/usr/bin/cmake" } } } }
However, when running the above configuration, I get an error that the CMake executable cannot be found at /usr/bin/cmake. Thus, the ${env:SDK_NATIVE_SYSROOT} seems to expand to an empty string. Interestingly, the same setting works when placed in .vscode/settings.json instead.
After further investigation, I think the issue is that ${env:...} in the customizations:vscode:settings is evaluated/expanded on the local host before being passed to the remote. Thus, ${env:SDK_NATIVE_SYSROOT} results in an empty string since it's only defined in the container, not on my local host. From my understanding, this is unintended behaviour as the customizations:vscode:settings are primarily to override settings specific to the devcontainer, and environment variables should be taken from the remoteEnv instead of localEnv.
Is there a way to escape ${env:...} or anything else that allows the use of SDK_NATIVE_SYSROOT from the container?
— Reply to this email directly, view it on GitHub https://github.com/devcontainers/spec/issues/485, or unsubscribe https://github.com/notifications/unsubscribe-auth/BIJZESKK77DRKH37VSIQJZ3ZQET3VAVCNFSM6AAAAABMDAMCJKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGQ2TCNRQGI2TKNI . You are receiving this because you are subscribed to this thread.Message ID: @.***>
There is currently no way to escape this. You can use ${containerEnv:SDK_NATIVE_SYSROOT}
instead.
Unfortunately, the ms-vscode.cmake-tools extension supports expanding ${env:...}
, but not ${containerEnv:...}
. I'll open a request ticket to support this in their project. Meanwhile, could you clarify why customizations:vscode:settings
in .devcontainer/devcontainer.json
behave differently from .vscode/settings.json
? Is it possible to define settings that are evaluated in the container and used only within it and not shared with a local workspace?
I’m setting up a
devcontainers.json
that works with our container images containing a cross-compiling SDK. In the Dockerfile, we already define anENV SDK_NATIVE_SYSROOT=/path/to/sdk
pointing to the path where the SDK is installed. We set thecmake.cmakePath
to make thems-vscode.cmake-tools
extension use the CMake executable from our SDK. According to its documentation,cmake.cmakePath
supports expanding${env:...}
variables. Thus, I tried to use the following in my.devcontainer/devcontainer.json
:However, when running the above configuration, I get an error that the CMake executable cannot be found at
/usr/bin/cmake
. Thus, the${env:SDK_NATIVE_SYSROOT}
seems to expand to an empty string. Interestingly, the same setting works when placed in.vscode/settings.json
instead.After further investigation, I think the issue is that
${env:...}
in thecustomizations:vscode:settings
is evaluated/expanded on the local host before being passed to the remote. Thus,${env:SDK_NATIVE_SYSROOT}
results in an empty string since it's only defined in the container, not on my local host. From my understanding, this is unintended behaviour as thecustomizations:vscode:settings
are primarily to override settings specific to the devcontainer, and environment variables should be taken from theremoteEnv
instead oflocalEnv
.Is there a way to escape
${env:...}
or anything else that allows the use ofSDK_NATIVE_SYSROOT
from the container?