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
2 changes: 1 addition & 1 deletion src/claude-code/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "claude-code",
"version": "2.0.1",
"version": "2.0.2",
"name": "claude-code",
"documentationURL": "http://github.com/devcontainers-extra/features/tree/main/src/claude-code",
"description": "Claude Code is an agentic coding tool that lives in your terminal",
Expand Down
14 changes: 11 additions & 3 deletions src/claude-code/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ set -e
# Install via Anthropic's recommended method
# Script downloaded from them:
# https://storage.googleapis.com/claude-code-dist-86c565f3-f756-42ad-8dfa-d59b1c096819/claude-code-releases/bootstrap.sh
bash "$(dirname "$0")/bootstrap.sh" "$VERSION"

# Resolve the absolute path before su changes the working directory
BOOTSTRAP_SCRIPT="$(pwd)/bootstrap.sh"

# Run as the devcontainer user so that ~/.claude/, ~/.local/bin/claude, and
# ~/.local/share/claude/ are owned by the right user, not root.
su - "$_REMOTE_USER" <<EOF
bash "$BOOTSTRAP_SCRIPT" "$VERSION"
EOF

# Copy the binary to /usr/local/bin for global access
# It's installed in /root/.local/bin/claude and there's no option to override the install location
cp "$HOME/.local/bin/claude" /usr/local/bin/claude
# It's installed in ~/.local/bin/claude and there's no option to override the install location
cp "$_REMOTE_USER_HOME/.local/bin/claude" /usr/local/bin/claude

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: _REMOTE_USER_HOME empty in certain setups?

Hi @brianhelba — after this PR landed, I'm seeing a build failure on line 20:

cp: cannot stat '/.local/bin/claude': No such file or directory
ERROR: Feature "claude-code" failed to install!

The su - "$_REMOTE_USER" step works fine (Claude installs successfully to the user's home), but the subsequent cp resolves to /.local/bin/claude — suggesting
_REMOTE_USER_HOME is empty in my build context.

My setup uses a custom base image (Ubuntu 24.04/CUDA) with common-utils creating the user and "remoteUser": "${localEnv:USER}" in the devcontainer config. Pinning
back to v2.0.0 resolves the issue.

Is _REMOTE_USER_HOME expected to always be available at this point in the feature lifecycle? Or would it be safer to fall back to resolving the home directory from
passwd, e.g.:

: "${_REMOTE_USER_HOME:=$(eval echo ~"$_REMOTE_USER")}"
cp "$_REMOTE_USER_HOME/.local/bin/claude" /usr/local/bin/claude


echo 'Done!'
2 changes: 2 additions & 0 deletions test/claude-code/test_debian.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,7 @@ set -e
source dev-container-features-test-lib

check "claude is installed" claude --version
check "~/.claude is owned by the current user" test "$(stat -c %u "$HOME/.claude")" = "$(id -u)"
check "~/.local/share/claude is owned by the current user" test "$(stat -c %u "$HOME/.local/share/claude")" = "$(id -u)"

reportResults
Loading