Skip to content
Latchkey

Works Locally but Fails in CI: How to Debug the Gap

The classic "but it works on my machine." The CI runner differs from your laptop in a handful of predictable ways.

CI-only failures almost always trace to an environment difference. Check these in order.

The usual suspects

DifferenceSymptom / fix
Case-sensitive filesystemLinux CI is case-sensitive; import "./Foo" vs foo.js fails - fix the casing
Missing dependency / toolInstalled locally, not on the runner - add it to the workflow or image
Uncommitted fileA file works locally but is not in Git - commit it
Time zone / localeCI runs UTC; date/locale-sensitive tests fail - pin TZ and locale
Resource limitsLess memory/CPU in CI causes OOM/timeouts - right-size or self-heal
Test ordering / parallelismCI runs tests differently - fix hidden test interdependencies
Clean install vs cached node_modulesUse npm ci so CI matches a clean lockfile install

Reproduce it fast

  • Run the job in a container matching the runner image locally.
  • Enable debug logging (ACTIONS_STEP_DEBUG) and re-run.
  • Open an interactive shell on the runner (tmate) to inspect the real environment.

Key takeaways

  • CI-only failures are environment differences, not magic.
  • Case sensitivity, missing deps, TZ/locale, and resources are the top causes.
  • Reproduce in a container matching the runner image.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →