From 5962aef5dd561bc0d5fe8d634b43aab48d51ba53 Mon Sep 17 00:00:00 2001 From: Brian Helba Date: Wed, 17 Jun 2026 11:10:53 -0400 Subject: [PATCH] Fix claude-code installing files owned by root `bootstrap.sh` was running as root, so `~/.claude/`, `~/.local/bin/claude`, and `~/.local/share/claude/` all ended up under `/root/` owned by root. The devcontainer user had no access to config or shell integration. Use the devcontainer spec variables `_REMOTE_USER` and `_REMOTE_USER_HOME` to run the install as the devcontainer user, following the pattern used by `asdf-package`, `homebrew-package`, and other features in this repo. --- src/claude-code/devcontainer-feature.json | 2 +- src/claude-code/install.sh | 14 +++++++++++--- test/claude-code/test_debian.sh | 2 ++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/claude-code/devcontainer-feature.json b/src/claude-code/devcontainer-feature.json index be0f0ab5d..ffc36ad8d 100644 --- a/src/claude-code/devcontainer-feature.json +++ b/src/claude-code/devcontainer-feature.json @@ -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", diff --git a/src/claude-code/install.sh b/src/claude-code/install.sh index ecc6b50df..1ab410ca0 100644 --- a/src/claude-code/install.sh +++ b/src/claude-code/install.sh @@ -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" <