code-server: [Bug]: code-server (run with docker) will always overwrite PATH variable
Is there an existing issue for this?
- I have searched the existing issues
OS/Web Information
- Remote OS: Ubunu
- Remote Architecture: amd64
code-server --version: both v4.7.0 and v4.0.1 are tried
Steps to Reproduce
- In a machine with docker installed, run
mkdir -p ~/.config docker run -it --name code-server -p 127.0.0.1:8080:8080 \ -v "$HOME/.config:/home/coder/.config" \ -v "$PWD:/home/coder/project" \ -u "$(id -u):$(id -g)" \ -e "DOCKER_USER=$USER" -e "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/some/path" \ codercom/code-server:latest - Login to the browser, launch terminal in vscode and print the PATH
echo $PATH - Always get:
Expected
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/some/path with some extra paths appended by code-server.
Actual
/usr/lib/code-server/lib/vscode/bin/remote-cli:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games
Logs
No response
Screenshot/Video
No response
Does this issue happen in VS Code or GitHub Codespaces?
- I cannot reproduce this in VS Code.
- I cannot reproduce this in GitHub Codespaces.
Are you accessing code-server over HTTPS?
- I am using HTTPS.
Notes
Though I checked I am using HTTPS, but I actually running locally without HTTPS. I checked it because it is a must and I think HTTPS has nothing to do with the issue.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 23 (23 by maintainers)
I tried the same thing with
debian:11(this is what code-server is based on) and reproduced:In
/etc/profilethere is this:So this could be the cause of the problem.
Can confirm that disabling
Terminal › Integrated: Inherit Envprevents the override.No. But see https://github.com/b-data/jupyterlab-python-docker-stack#run-container
Adapted to your example:
ℹ️ Run the command in an empty directory so that the container populates it.
👉
-e CHOWN_HOME=1and-e CHOWN_HOME_OPTS=-Ris only required at first run.How did I not find out the previous issue 😲 I searched that…
Prepending
/usr/lib/code-server/lib/vscode/bin/remote-clitoPATHis not a bug but by design.Cross references:
Looks good. These are fine if documented I think.
That seems chill. Maybe we can do the Docker tags like this:
I patterned that after the Python image but maybe in code-server’s case it makes more sense to do it by OS.
We could also do both.
For a login shell, I think the path set in the Dockerfile or pass from the
docker runcommand should be respected. See:So I think either vscode modifies the PATH or code-server modifies it. It is more likely that the code-server modifies it as the local instance of vscode runs without this issue.
Yeah it looks ilke the “inherit env” name is misleading. It seems to mean that it spawns a login shell to get the environment rather than using the current environment (which sounds backwards from “inherit” to me 🤷 but I guess that is the name they went with).
So to summarize:
Oh wait I think I might know what it is! I think VS Code spawns a login shell to get
PATH. So basically they run something likebash -lc "printenv PATH"and then set PATH to that. Edit: actually it seems they source the entire environment not justPATHas seen here then merge it with the current environment.There are some terminal settings like
Inherit Envthat we might want to play around with to see if we can stop it from doing that.