cli icon indicating copy to clipboard operation
cli copied to clipboard

Variable substitution for environment variables does not work when using the command line argument --remote-env

Open thomasmerx opened this issue 1 year ago • 3 comments

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

thomasmerx avatar Sep 14 '23 07:09 thomasmerx

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 👇

image

samruddhikhandale avatar Sep 14 '23 23:09 samruddhikhandale

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.

thomasmerx avatar Sep 15 '23 05:09 thomasmerx

I see your point, looks like it has to do something with the host login shells. Looping in @chrmarti.

samruddhikhandale avatar Sep 15 '23 16:09 samruddhikhandale