Skip to content

chore: prevent root-owned npm cache files in agent environments #417

Description

@mogul

Problem

During local verification for release-installer work, npm run lint:md was initially blocked because the npm cache under /home/agent/.npm contained files owned by root. The immediate workaround was to run:

sudo chown -R 1000:1000 /home/agent/.npm

That unblocked markdown linting, but it points to an environment/bootstrap issue: npm commands can leave cache files owned by the wrong user if any setup step runs npm as root or with sudo while using the agent user's npm cache path.

Impact

  • Local verification can fail for unrelated code changes.
  • Agents may need elevated cleanup just to run normal lint commands.
  • The failure is confusing because it presents as an npm cache permission problem rather than a project lint failure.

Expected Behavior

The agent user's npm cache should remain writable by the agent user after bootstrap and verification commands. Running npm run lint:md should not require sudo or cache ownership repair.

Suggested Remediation

  • Identify where npm is being run with elevated privileges or an inherited cache path.
  • Ensure bootstrap/install steps do not write root-owned files into /home/agent/.npm.
  • Consider setting an agent-local npm cache path during privileged installation steps if sudo is unavoidable.
  • Add a lightweight environment health check or troubleshooting note if this can occur outside repository control.

Verification

After remediation, this should pass without a preceding ownership repair:

npm run lint:md

The cache should also show files owned by the agent user, not root:

find /home/agent/.npm -not -user "$(id -u)" -print

Context

This was observed while working in GSA-TTS/agentic-coding-quickstart during local verification. The local fix was applied manually with passwordless sudo, but the underlying cause remains worth tracking so future agent sessions do not hit the same blocker.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions