cli
cli copied to clipboard
Variable substitution for environment variables does not work when using the command line argument --remote-env
I tried to extend the PATH environment variable used inside the container from the command line like this:
devcontainer exec --remote-env PATH='${containerEnv:PATH}':/my-additional-path --workspace-folder . bash
However, it seems the variable substitution does not work here. When I add the same to the devcontainer.json, then the variable substitution works as expected.
Am I doing something wrong, or is it just not implemented? If not, would it be possible to add this feature?
Thanks, Thomas
Hi 👋
Can you try the following command, instead? I don't think containerEnv:PATH
will be accessible.
devcontainer exec --remote-env PATH="$PATH:my-additional-path" --workspace-folder . bash
See 👇
Hi Samruddhi,
thanks for the suggestion. I know that this works, but the result is not the same. In your example the internal PATH variable of the container gets replaced with the PATH variable of the host plus the additional path, which is done by the shell of the host.
From my point of view the behaviour should be consistent, no matter if I use the devcontainer.json remoteEnv option or the command line argument --remote-env. I don't see a reason why the remoteEnv option is processed by the variable substitution filter, while the --remote-env from the command line is not.
I see your point, looks like it has to do something with the host login shells. Looping in @chrmarti.