Skip to content

Fix claude-code installing files owned by root#229

Merged
koralowiec merged 1 commit into
devcontainers-extra:mainfrom
brianhelba:claude-code-ownership
Jun 18, 2026
Merged

Fix claude-code installing files owned by root#229
koralowiec merged 1 commit into
devcontainers-extra:mainfrom
brianhelba:claude-code-ownership

Conversation

@brianhelba

Copy link
Copy Markdown
Contributor

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.

@brianhelba brianhelba force-pushed the claude-code-ownership branch from ec18a5b to a135a54 Compare June 17, 2026 15:27

@koralowiec koralowiec left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hi, please bump the feature version from 2.0.1 to 2.0.2

`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.
@brianhelba brianhelba force-pushed the claude-code-ownership branch from a135a54 to 5962aef Compare June 17, 2026 19:38
@brianhelba

Copy link
Copy Markdown
Contributor Author

@koralowiec Done.

@brianhelba brianhelba requested a review from koralowiec June 17, 2026 19:39
@koralowiec koralowiec merged commit b936f8b into devcontainers-extra:main Jun 18, 2026
5 checks passed
# 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

@brianhelba

Copy link
Copy Markdown
Contributor Author

According to the dev container spec, the _REMOTE_USER_HOME env variable should be defined at feature install time. However, maybe this bug is causing it to be unset.

@ZhiliangWu I think it's reasonable to add a fallback. I'll be happy to review a PR if you want to make one.

@brianhelba brianhelba deleted the claude-code-ownership branch June 19, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants