question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug]: code-server (run with docker) will always overwrite PATH variable

See original GitHub issue

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

  1. 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
    
  2. Login to the browser, launch terminal in vscode and print the PATH echo $PATH
  3. 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.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:23 (18 by maintainers)

github_iconTop GitHub Comments

3reactions
code-ashercommented, Oct 5, 2022

I tried the same thing with debian:11 (this is what code-server is based on) and reproduced:

coder@my-dev2:~/docker$ docker run --rm -e "PATH=/usr/bin:/bin:/some-path" -it debian:11 bash
root@25b75f4f2da6:/# printenv PATH
/usr/bin:/bin:/some-path
root@25b75f4f2da6:/# bash -lc 'printenv PATH'
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

In /etc/profile there is this:

if [ "$(id -u)" -eq 0 ]; then
  PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
  PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi

So this could be the cause of the problem.

2reactions
benz0licommented, Oct 5, 2022

I am not familiar with it. It seems I cannot customize in the demo- mode.

No. But see https://github.com/b-data/jupyterlab-python-docker-stack#run-container


Adapted to your example:

docker run -it --name jupyter-code-server \
  -u root \
  -p 8888:8888 \
  -v $PWD:/home/$USER \
  -e NB_USER=$USER \
  -e NB_UID=$(id -u) \
  -e NB_GID=$(id -g) \
  -e CHOWN_HOME=1 \
  -e CHOWN_HOME_OPTS=-R \
  -e PATH=/opt/TinyTeX/bin/linux:/opt/quarto/bin:/opt/code-server/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/some/path \
  registry.gitlab.b-data.ch/jupyterlab/python/scipy

ℹ️ Run the command in an empty directory so that the container populates it.
👉 -e CHOWN_HOME=1 and -e CHOWN_HOME_OPTS=-R is only required at first run.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Docker Tools Tips and Tricks - Visual Studio Code
DOCKER_HOST attribute will override your Docker context and the DOCKER_HOST environment variable will override both the docker.environment.DOCKER_HOST attribute ...
Read more >
FAQ - code-server v4.8.0 docs - Coder
Frequently asked questions on installing and running code-server. ... If you set the XDG_DATA_HOME environment variable, the data directory will be ...
Read more >
Code Server Installed on Docker - YouTube
In this video we' ll take a look at a Docker container that has been requested multiple times in my comments section: Code-Server....
Read more >
How to set an environment variable in a running docker ...
There are generaly two options, because docker doesn't support this feature now: Create your own script, which will act like runner for your ......
Read more >
How To Set Up the code-server Cloud IDE Platform on Ubuntu ...
This means that you can use various devices running different operating systems, and always have a consistent development environment on hand.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found