Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .devcontainer/10-devcontainer-tools.sh
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 11 additions & 0 deletions scripts/verify-devcontainer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down