Skip to content

Commit 0b48956

Browse files
chapterjasonclaude
andcommitted
Fix claude-code install at unsupported location (3.0.0)
The previous install copied the launcher shim from $HOME/.local/bin to /usr/local/bin, which trips Claude Code's "unsupported install location" check (the auto-updater can only manage paths matching the canonical .claude/local/ + .local/bin/ layout) and breaks the launcher, which expects supporting files at its original $HOME-relative path. Run the official native installer with HOME pointed at the remote user's home, producing the canonical layout, then chown the result. Same root-not-sudo pattern as the nvm feature. Major bump because the binary location changes. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 703f7c0 commit 0b48956

2 files changed

Lines changed: 13 additions & 16 deletions

File tree

src/claude-code/devcontainer-feature.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"id": "claude-code",
3-
"version": "2.1.1",
3+
"version": "3.0.0",
44
"name": "claude-code",
5-
"description": "Installs the latest Claude Code CLI via the official native installer, placing the binary in /usr/local/bin. Declares ~/.claude and ~/.claude.json as persistence targets via the home-persist manifest, so credentials, sessions, and plugins survive rebuilds when home-persist is installed.",
5+
"description": "Installs the latest Claude Code CLI via the official native installer into the remote user's home (~/.claude/local + ~/.local/bin), the layout the auto-updater expects. Declares ~/.claude and ~/.claude.json as persistence targets via the home-persist manifest, so credentials, sessions, and plugins survive rebuilds when home-persist is installed.",
66
"documentationURL": "https://github.com/SoureCode/devcontainer-features/tree/master/src/claude-code",
77
"dependsOn": {
88
"ghcr.io/sourecode/devcontainer-features/nvm:2": {}

src/claude-code/install.sh

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,24 @@
11
#!/usr/bin/env bash
22
# claude-code feature installer.
3-
#
4-
# Requires Node.js on PATH (provided by the nvm feature via `dependsOn`).
5-
# Installs the binary to /usr/local/bin so it lives in an image layer,
6-
# independent of the persistence volume, and declares the HOME paths that
7-
# need to survive rebuilds via the home-persist manifest.
83
set -e
94

10-
if ! command -v curl >/dev/null 2>&1; then
11-
apt-get update
12-
apt-get install -y --no-install-recommends curl ca-certificates
13-
rm -rf /var/lib/apt/lists/*
5+
USER_NAME="${_REMOTE_USER:-${USERNAME:-root}}"
6+
if [ "$USER_NAME" = "root" ]; then
7+
USER_GROUP="root"
8+
else
9+
USER_GROUP="$(id -gn "$USER_NAME")"
1410
fi
1511

16-
curl -fsSL https://claude.ai/install.sh | bash
12+
USER_HOME="$(getent passwd "$USER_NAME" | cut -d: -f6)"
1713

18-
SRC_BIN="$HOME/.local/bin/claude"
19-
if [ ! -x "$SRC_BIN" ]; then
20-
echo "claude-code feature: expected $SRC_BIN after install, but it was not found." >&2
14+
HOME="$USER_HOME" curl -fsSL https://claude.ai/install.sh | HOME="$USER_HOME" bash
15+
16+
if [ ! -x "$USER_HOME/.local/bin/claude" ]; then
17+
echo "claude-code feature: expected $USER_HOME/.local/bin/claude after install, but it was not found." >&2
2118
exit 1
2219
fi
2320

24-
install -m 0755 "$SRC_BIN" /usr/local/bin/claude
21+
chown -R "$USER_NAME:$USER_GROUP" "$USER_HOME/.claude" "$USER_HOME/.local"
2522

2623
# Declare the HOME paths Claude Code needs persisted. The home-persist feature
2724
# reads every /etc/devcontainer-persist.d/*.json at create time and symlinks

0 commit comments

Comments
 (0)