Skip to content
Latchkey

Go "fork/exec /tmp: permission denied" - Fix in CI

go test builds a test binary into a temp directory and execs it. When /tmp is mounted noexec or otherwise restricted, the exec is denied and the test cannot run.

What this error means

A test fails with fork/exec /tmp/go-buildNNN/b001/x.test: permission denied. The temp directory is mounted noexec or lacks execute permission.

go
fork/exec /tmp/go-build123456/b001/app.test: permission denied

Common causes

/tmp mounted noexec

The temp filesystem disallows execution, so the freshly built test binary cannot run.

Restricted TMPDIR permissions

The temp directory lacks execute permission for the build user.

How to fix it

Use an exec-allowed TMPDIR

  1. Point TMPDIR at a directory that permits execution.
.github/workflows/ci.yml
- run: |
    mkdir -p "$RUNNER_TEMP/gotmp"
    TMPDIR="$RUNNER_TEMP/gotmp" go test ./...

Remount with exec if you control the host

  1. Remount the temp filesystem allowing execution.
shell
sudo mount -o remount,exec /tmp

How to prevent it

  • Set TMPDIR to an exec-allowed path in CI.
  • Avoid noexec mounts for directories Go builds into.
  • Verify TMPDIR permissions early in the job.

Related guides

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