Skip to content
Latchkey

GitHub Actions container job "HOME is not set"

Some container images run as a user with no HOME defined, or HOME points at a path that is not writable in the runner mount. Tools that write config or caches under HOME then fail.

What this error means

A step inside a container job fails because a tool cannot resolve or write to the home directory.

github-actions
npm error code ENOENT
npm error path /nonexistent/.npmrc
npm error errno -2
##[error]Process completed with exit code 254.

Common causes

Image user has no HOME

A minimal image runs as a UID with no /etc/passwd entry, so HOME is empty and tools fall back to "/" or "/nonexistent".

HOME points outside the writable mount

The default HOME path is read-only inside the container, blocking config and cache writes.

How to fix it

Set HOME to a writable path

  1. Export HOME (and any tool-specific cache dirs) to a path under the workspace.
  2. Create the directory before the tool runs.
  3. Re-run.
.github/workflows/ci.yml
- name: Configure HOME
  run: echo "HOME=${GITHUB_WORKSPACE}" >> "${GITHUB_ENV}"
- run: |
    npm config set cache "${GITHUB_WORKSPACE}/.npm"
    npm ci

How to prevent it

  • Set HOME explicitly for container jobs built on minimal images.
  • Point tool caches at the workspace so they are writable and cacheable.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →