C
Coder.com•10mo ago
Syrelash

Modify $PATH to include custom bin folder

Good morning y'all, How do I modify my vs code (desktop) $PATH for my container? One of my extensions requires Java, Current PATH: /root/.vscode-server/cli/servers/Stable-fabdb6a30b49f79a7aba0f2ad9df9b399473380f/server/bin/remote-cli:/usr/local/share/nvm/current/bin:/usr/local/share/npm-global/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.local/bin:/root/.vscode-server/data/User/globalStorage/github.copilot-chat/debugCommand I tried adding RUN echo "export PATH=$PATH" > /etc/environment to my Dockerfile, and "runArgs": ["--env-file",".devcontainer/devcontainer.env"] to my dev container json. Neither of those seem to carry over to the visual studio code though.
12 Replies
Codercord
Codercord•10mo ago
<#1323673871290732554>
Category
Help needed
Product
Coder (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
Some Dinosaur
Some Dinosaur•10mo ago
I just added this to my Dockerfile:
ENV PATH="$PATH:/uhh/idk/"
ENV PATH="$PATH:/uhh/idk/"
and it seems to work:
$ echo $PATH
/tmp/code-server/lib/code-server-4.96.2/lib/vscode/bin/remote-cli:/usr/local/cargo/bin:/usr/local/cargo/bin:/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.local/bin:/uuh/idk/
$ echo $PATH
/tmp/code-server/lib/code-server-4.96.2/lib/vscode/bin/remote-cli:/usr/local/cargo/bin:/usr/local/cargo/bin:/usr/local/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.local/bin:/uuh/idk/
I never used /etc/environment but internet says it doesn't support export so it only allows you to set some static variables I guess? I think doing it your way might work if you've used ~/.bashrc instead but then it's per-user
Syrelash
SyrelashOP•10mo ago
Hmm.. I have ENV JAVA_HOME /usr/lib/jvm/msopenjdk-current ENV PATH "${JAVA_HOME}/bin:${PATH}" in my Dockerfile. For some reason that doesn't put JAVA_HOME in my $PATH. JAVA_HOME is correctly set though because I can echo it. Okay. I stopped trying to add Java via the Dockerfile, and instead added the feature "ghcr.io/devcontainers/features/java:1": { "version": 17 } which seems to work. Thanks for your help everyone.
Phorcys
Phorcys•10mo ago
yes, that is the intended way it's probably being overwritten by the devcontainer interpreter, to add any environment variables you should use containerEnv, but for your use-case i'd still recommend using the java feature https://containers.dev/implementors/json_reference/#general-properties
Codercord
Codercord•10mo ago
@Phorcys closed the thread.
Drago
Drago•3mo ago
Hello, guys, Isn't there a way to stop the PATH variable set in the docker image to be overwritten by vscode without setting it manually in the vscode client side via devcontainer.json or any client side solution?
Phorcys
Phorcys•3mo ago
are you setting the PATH variable in the Dockerfile and then using that Dockerfile in the devcontainer.json file?
Drago
Drago•3mo ago
I am setting the PATH in the Dockerfile but i was not aware that the use of a devcontainer.json file was mandatory. The devcontainer.json can be defined at the template and the workspace will automatically use the devcontainer.json configs when the user clicks on "VS Code Desktop" to open?
Phorcys
Phorcys•3mo ago
it is not mandatory, I just assulmed you were using it because this is what the thread was about! can you open another #help thread for your issue?
Drago
Drago•3mo ago
Sure! My bad for reusing this thread 😅
Phorcys
Phorcys•3mo ago
it's all good -- i just don't want to get the two mixed up
Codercord
Codercord•3mo ago
@Phorcys closed the thread.

Did you find this page helpful?