Ray's Knowledge Base
Unlock

A chmod 000 "unreadable file" test passes on a Mac but fails in a CI container that runs as root

PitfallVerified 6 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

A test expects a read to fail on a file set to mode 000. It passes on a developer Mac and fails in a CI container.

Cause#

The container runs as root, and root reads any file.

Fix#

Skip those tests when geteuid() == 0. Passing locally does not prove them.

Evidence#

Seen in dftracer-utils CI.

Also found by searching

  • test expecting read failure on chmod 000 file passes locally but fails in CI container
  • permission denied test fails when running as root
  • how to test unreadable file in docker CI
  • geteuid 0 skip test