fix: resolve EACCES permission error in javascript profile#102
Open
b00y0h wants to merge 1 commit into
Open
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdjusts Docker-based JavaScript profile setup to fix npm EACCES errors by correcting ownership of the nvm directory before switching to the non-root claude user. Sequence diagram for Docker JavaScript profile setup and permission fixsequenceDiagram
actor Developer
participant Claudebox
participant DockerEngine
participant Container_root as Container_root_user
participant Container_claude as Container_claude_user
participant NVMDir as NVM_directory
participant NPM
Developer->>Claudebox: claudebox add javascript
Claudebox->>DockerEngine: Build JavaScript profile image
DockerEngine->>Container_root: Execute RUN install nvm
Container_root->>NVMDir: Create and own /home/claude/.nvm
DockerEngine->>Container_root: Execute RUN nvm install --lts
%% New step introduced by PR
DockerEngine->>Container_root: Execute RUN chown -R claude:claude $NVM_DIR
Container_root->>NVMDir: Change ownership to claude
DockerEngine->>Container_root: Switch USER claude
Container_root-->>Container_claude: User context changes
DockerEngine->>Container_claude: RUN npm install -g typescript eslint prettier yarn pnpm
Container_claude->>NVMDir: Write to node_modules
NVMDir-->>Container_claude: Write succeeds (no EACCES)
Container_claude->>NPM: Global packages installed successfully
Flow diagram for updated JavaScript profile Docker build stepsflowchart TD
A[Start Docker build for JavaScript profile] --> B[RUN install nvm as root]
B --> C[Set ENV NVM_DIR=/home/claude/.nvm]
C --> D[RUN source nvm.sh and nvm install --lts]
D --> E[RUN chown -R claude:claude $NVM_DIR]
E --> F[USER claude]
F --> G[RUN npm install -g typescript eslint prettier yarn pnpm]
G --> H[Switch back USER root]
H --> I[Image build continues without EACCES error]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Instead of installing nvm as root and then chown’ing the directory, consider switching to
USER claudebefore the nvm install so the install and subsequentnpm install -gboth run as the same user and avoid needing a recursive ownership fix. - You might want to combine the nvm install and chown into a single
RUNlayer with&&so that the ownership change doesn’t run if the install fails and to keep the Docker image history cleaner.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Instead of installing nvm as root and then chown’ing the directory, consider switching to `USER claude` before the nvm install so the install and subsequent `npm install -g` both run as the same user and avoid needing a recursive ownership fix.
- You might want to combine the nvm install and chown into a single `RUN` layer with `&&` so that the ownership change doesn’t run if the install fails and to keep the Docker image history cleaner.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
d0fd63e to
3a1c67b
Compare
The core image already installs nvm, node, and claude-code for the claude user. The javascript profile only needs to add dev tool packages (typescript, eslint, prettier, yarn, pnpm). Previously the profile reinstalled nvm and node as root, which caused two issues: - chown claude:claude failed when the 'claude' group didn't exist (GID collision with system groups like dialout on Debian) - Even when chown succeeded, reinstalling nvm/node clobbered the core image's node version where claude-code was installed Fix: switch to USER claude and install only the additional global npm packages using the existing nvm/node from the core image.
3a1c67b to
60d7d4b
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_profile_javascript()function installs nvm as root, but then switches toUSER claudebefore runningnpm install -g. Since the nvm directory (/home/claude/.nvm) is owned by root, the claude user getsEACCES: permission deniedwhen npm tries to write tonode_modules.RUN chown -R claude:claude $NVM_DIRbefore theUSER claudeswitch to fix directory ownership.Steps to reproduce
claudebox add javascriptclaudebox— build fails atnpm install -gwith EACCES errorTest plan
claudebox add javascriptfollowed byclaudeboxand verify the Docker build completes successfullytypescript,eslint,prettier,yarn, andpnpmare available inside the containerSummary by Sourcery
Bug Fixes: