Skip to content
Latchkey

Dockerfile RUN "not found" exit code 127 in CI

A RUN step called a command the shell could not find, so it exited 127. The tool is not installed in this stage, is in a different stage, or the name is misspelled.

What this error means

A RUN step prints "/bin/sh: 1: yarn: not found" (Debian dash) or "yarn: command not found" (bash), then the build summary shows exit code 127.

docker build
/bin/sh: 1: yarn: not found
ERROR: failed to solve: process "/bin/sh -c yarn install" did not complete successfully: exit code: 127

Common causes

The tool is not installed in this stage

The package providing the command was never installed, or it was installed in a different build stage that this one does not inherit.

A typo or wrong PATH

A misspelled command, or a binary installed to a directory not on PATH, both surface as "not found" with exit 127.

How to fix it

Install the tool in the same stage

Add the package that provides the command before you call it.

Dockerfile
RUN apt-get update && apt-get install -y --no-install-recommends git \
 && rm -rf /var/lib/apt/lists/*
RUN git --version

Check the name and PATH

  1. Confirm the exact command name and spelling.
  2. Verify the install directory is on PATH in this stage.
  3. For Alpine, install with apk add rather than apt-get.

How to prevent it

  • Install required tools in the stage that uses them.
  • Verify command names and PATH before relying on them.
  • Remember exit 127 specifically means command-not-found.

Frequently asked questions

What causes ""/bin/sh: 1: X: not found""?
The package providing the command was never installed, or it was installed in a different build stage that this one does not inherit.
How do I fix "/bin/sh: 1: X: not found"?
Add the package that provides the command before you call it.

Related guides

References

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