Skip to content
Latchkey

Nim "execution of an external program failed: gcc" in CI

Nim compiles to C and then invokes a C compiler to produce the binary. This error means that gcc step failed, either because gcc is absent on the runner or because compiling or linking the generated C errored.

What this error means

After Nim finishes its own pass, the build fails with "Error: execution of an external program failed: 'gcc ...'". The real gcc output appears just above the line.

nim
Error: execution of an external program failed: 'gcc -c -w ... @m..@smain.nim.c.o ...'

Common causes

No C compiler on the runner

A slim image without build-essential has no gcc, so Nim cannot run the backend compile step.

The generated C failed to compile or link

A missing system header, a missing C library, or a link error in the generated C makes gcc exit non-zero; Nim reports it as an external program failure.

How to fix it

Install a C toolchain on the runner

Provide gcc and the standard headers before the Nim build.

Terminal
sudo apt-get update && sudo apt-get install -y build-essential

Read the captured gcc output

  1. Scroll up to the gcc error printed above the Nim line.
  2. Install the missing dev header or library it names (for example "cannot find -lpcre" needs libpcre3-dev).
  3. Re-run; the Nim line clears once gcc succeeds.

How to prevent it

  • Install build-essential before Nim builds on slim images.
  • Add required -dev system packages for C-linking dependencies.
  • Read the gcc output above the Nim summary to find the real cause.

Related guides

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