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.
5 Replies
Codercord
Codercord4w ago
<#1323673871290732554>
Category
Help needed
Product
Coder (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
Some Dinosaur
Some Dinosaur4w 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
SyrelashOP4w 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
Phorcys4w 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
Codercord4w ago
@Phorcys closed the thread.

Did you find this page helpful?