Skip to content
Latchkey

Docker "failed to compute cache key: failed to walk" (Broken Symlink) in CI

BuildKit could not walk the build context to compute a COPY cache key. failed to walk <path> means a path in the context - usually a broken/dangling symlink or an unreadable entry - could not be traversed.

What this error means

A COPY step fails with failed to compute cache key: failed to walk /<path>: lstat ...: no such file or directory, pointing at a symlink whose target is missing or outside the context.

docker
ERROR: failed to solve: failed to compute cache key: failed to walk /var/lib/buildkit/.../node_modules/.bin/foo:
lstat /var/lib/buildkit/.../node_modules/.bin/foo: no such file or directory
# .bin/foo is a symlink whose target is missing

Common causes

A dangling symlink in the context

A symlink whose target was removed (or points outside the context) cannot be resolved while walking, so the cache-key computation fails.

A symlink that escapes the context

A symlink pointing to an absolute path outside the build context cannot be traversed by BuildKit and breaks the walk.

An unreadable entry in a copied directory

A path the builder cannot stat (permissions, special file) during the walk fails the cache-key step.

How to fix it

Exclude or fix the broken symlink

Keep the dangling symlink out of the context or repair its target.

.dockerignore
# .dockerignore - keep generated/linked trees out of the context
node_modules
**/.bin

Copy only the directories you need

Narrow the COPY so the walk never touches the broken link.

Dockerfile
# copy sources, then install in-image (no host symlinks copied)
COPY package*.json ./
RUN npm ci
COPY src/ ./src/

How to prevent it

  • Exclude generated/symlinked directories (e.g. node_modules) via .dockerignore.
  • Install dependencies in-image rather than copying host symlink trees.
  • Avoid symlinks in the context that point outside it.

Frequently asked questions

What causes ""failed to compute cache key: failed to walk""?
A symlink whose target was removed (or points outside the context) cannot be resolved while walking, so the cache-key computation fails.
How do I fix "failed to compute cache key: failed to walk"?
Keep the dangling symlink out of the context or repair its target.

Related guides

References

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