From 137baa680056fc0273ff438ad8c4adda63948110 Mon Sep 17 00:00:00 2001 From: Brian Morton Date: Fri, 30 Oct 2026 06:49:33 +0000 Subject: [PATCH] Put mise shims and Go/Cargo bins on PATH in login shells Debian's /etc/profile resets PATH for login shells and the base image's 00-restore-env.sh only restores the PATH it saw at base-image build time, so the ENV PATH added by this Dockerfile disappeared in `coder ssh`, VS Code terminals and tmux windows ("tmux: command not found", "go: command not found") even though CI's non-login init script saw everything. Install /etc/profile.d/10-devcontainer-tools.sh (exports the mise variables and prepends the tool dirs idempotently) and source it from /etc/bash.bashrc and /etc/zsh/zshrc, as the devcontainer features used to do. The verify script now also checks tool visibility from bash -l and zsh -l so this cannot regress silently. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01AihTX41wWUjfBk3c2A9h2Z --- .devcontainer/10-devcontainer-tools.sh | 8 ++++++++ .devcontainer/Dockerfile | 12 ++++++++++++ scripts/verify-devcontainer.sh | 11 +++++++++++ 3 files changed, 31 insertions(+) create mode 100644 .devcontainer/10-devcontainer-tools.sh diff --git a/.devcontainer/10-devcontainer-tools.sh b/.devcontainer/10-devcontainer-tools.sh new file mode 100644 index 0000000..0c4e214 --- /dev/null +++ b/.devcontainer/10-devcontainer-tools.sh @@ -0,0 +1,8 @@ +# Installed by .devcontainer/Dockerfile: mise shims and Go/Cargo bin dirs. +export MISE_DATA_DIR=/usr/local/share/mise MISE_TRUSTED_CONFIG_PATHS=/etc/mise +export GOPATH=/go RUSTUP_HOME=/usr/local/rustup CARGO_HOME=/usr/local/cargo +for _d in "$CARGO_HOME/bin" "$GOPATH/bin" "$MISE_DATA_DIR/shims"; do + case ":$PATH:" in *":$_d:"*) ;; *) PATH="$_d:$PATH" ;; esac +done +unset _d +export PATH diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 798df06..994b987 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -92,6 +92,18 @@ COPY mise.toml /etc/mise/config.toml RUN mkdir -p "${MISE_DATA_DIR}" "${GOPATH}" "${RUSTUP_HOME}" "${CARGO_HOME}" \ && chown -R node:node "${MISE_DATA_DIR}" "${GOPATH}" "${RUSTUP_HOME}" "${CARGO_HOME}" +# Login shells do not see the ENV PATH above: Debian's /etc/profile resets PATH +# and the base image's /etc/profile.d/00-restore-env.sh only restores the PATH +# that existed when the base image was built. `coder ssh`, VS Code terminals and +# new tmux windows are all login shells, so without this the tools "vanish" +# (CI's init script is non-login and never noticed). Export the tool dirs and +# mise variables from a profile.d snippet and source it from the interactive rc +# files too, exactly as the devcontainer features used to do. +COPY 10-devcontainer-tools.sh /etc/profile.d/10-devcontainer-tools.sh +RUN chmod 0644 /etc/profile.d/10-devcontainer-tools.sh \ + && printf '\n. /etc/profile.d/10-devcontainer-tools.sh\n' >> /etc/bash.bashrc \ + && printf '\n. /etc/profile.d/10-devcontainer-tools.sh\n' >> /etc/zsh/zshrc + # Install as `node` so the shared tool tree is owned by the user who will add # to it (gems, `go install`, `cargo install`, `mise use`). root can still run # and modify everything. diff --git a/scripts/verify-devcontainer.sh b/scripts/verify-devcontainer.sh index bbb387f..e1e1e5c 100755 --- a/scripts/verify-devcontainer.sh +++ b/scripts/verify-devcontainer.sh @@ -118,6 +118,17 @@ if command -v mise >/dev/null 2>&1; then fail "$tool is missing or fails to run ($tool $args)" fi done + # Login shells (coder ssh, VS Code terminal, tmux windows) reset PATH via + # /etc/profile; make sure the tools are still reachable there, in bash and zsh. + for sh in bash zsh; do + if command -v "$sh" >/dev/null 2>&1; then + if "$sh" -lc 'command -v tmux >/dev/null && command -v go >/dev/null && command -v mise >/dev/null' 2>/dev/null; then + pass "tools are on PATH in a $sh login shell" + else + fail "tools are NOT on PATH in a $sh login shell (PATH=$("$sh" -lc 'echo $PATH' 2>/dev/null))" + fi + fi + done if [ -x /usr/local/bin/nsc ]; then pass "nsc installed" else