Skip to content

fix: resolve EACCES permission error in javascript profile#102

Open
b00y0h wants to merge 1 commit into
RchGrav:mainfrom
b00y0h:fix/javascript-profile-permissions
Open

fix: resolve EACCES permission error in javascript profile#102
b00y0h wants to merge 1 commit into
RchGrav:mainfrom
b00y0h:fix/javascript-profile-permissions

Conversation

@b00y0h
Copy link
Copy Markdown

@b00y0h b00y0h commented Feb 13, 2026

Summary

  • The get_profile_javascript() function installs nvm as root, but then switches to USER claude before running npm install -g. Since the nvm directory (/home/claude/.nvm) is owned by root, the claude user gets EACCES: permission denied when npm tries to write to node_modules.
  • Adds RUN chown -R claude:claude $NVM_DIR before the USER claude switch to fix directory ownership.

Steps to reproduce

  1. claudebox add javascript
  2. Run claudebox — build fails at npm install -g with EACCES error

Test plan

  • Run claudebox add javascript followed by claudebox and verify the Docker build completes successfully
  • Verify typescript, eslint, prettier, yarn, and pnpm are available inside the container

Summary by Sourcery

Bug Fixes:

  • Correct NVM directory ownership so the claude user can run global npm installs without EACCES permission errors.

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Feb 13, 2026

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adjusts 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 fix

sequenceDiagram
    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
Loading

Flow diagram for updated JavaScript profile Docker build steps

flowchart 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]
Loading

File-Level Changes

Change Details Files
Ensure nvm directory ownership is compatible with npm global installs under the non-root claude user.
  • Set NVM_DIR environment variable to /home/claude/.nvm prior to using nvm
  • Add a chown command to recursively assign the nvm directory to the claude user and group before switching users
  • Keep npm global package installation (typescript, eslint, prettier, yarn, pnpm) under the claude user context, then restore root user
lib/config.sh

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've left some high level feedback:

  • 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@b00y0h b00y0h force-pushed the fix/javascript-profile-permissions branch 2 times, most recently from d0fd63e to 3a1c67b Compare February 13, 2026 00:35
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.
@b00y0h b00y0h force-pushed the fix/javascript-profile-permissions branch from 3a1c67b to 60d7d4b Compare February 13, 2026 00:40
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.

1 participant