Skip to content
Latchkey

"yarn: command not found" during a Rails asset build in CI

The Rails asset pipeline (Webpacker or jsbundling-rails) shells out to Yarn, but Yarn is not installed on the runner. Without it the JS build cannot run and precompile fails.

What this error means

assets:precompile or the asset build aborts complaining Yarn is not installed or could not be detected, often with a hint to run yarn install. Boot works; the JS build does not.

rails
Yarn executable was not detected in the system.
Download Yarn at https://yarnpkg.com/en/docs/install
rake aborted! (webpacker:check_yarn)

Common causes

Yarn not installed on the runner

The base image or job did not install Yarn, but Webpacker/jsbundling requires it for the JS build.

Node missing too

Neither Node nor Yarn was set up, so the JS toolchain is entirely absent.

yarn install not run

Yarn exists but node_modules was never installed, so the build fails for missing JS dependencies.

How to fix it

Install Node, enable Yarn, and install deps

Modern Node ships Corepack, which provides Yarn.

.github/workflows/ci.yml
# .github/workflows/ci.yml
- uses: actions/setup-node@v4
  with: { node-version: 20 }
- run: corepack enable
- run: yarn install --frozen-lockfile
- run: bundle exec rails assets:precompile

How to prevent it

  • Set up Node (and enable Corepack/Yarn) before any Rails asset build.
  • Run yarn install before precompiling.
  • Pin the Node/Yarn versions the project expects.

Frequently asked questions

What causes ""yarn not found""?
The base image or job did not install Yarn, but Webpacker/jsbundling requires it for the JS build.
How do I fix "yarn not found"?
Modern Node ships Corepack, which provides Yarn.

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card