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
<#1323673871290732554>
Category
Help needed
Product
Coder (v2)
Platform
Linux
Logs
Please post any relevant logs/error messages.
I just added this to my
Dockerfile
:
and it seems to work:
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-userHmm.. 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.
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
@Phorcys closed the thread.