Skip to content

fix: remove --test_tmpdir that conflicts with --sandbox_tmpfs_path#23

Merged
Sam-Si merged 4 commits into
mainfrom
fix/bazel-sandbox-mount-failure
May 10, 2026
Merged

fix: remove --test_tmpdir that conflicts with --sandbox_tmpfs_path#23
Sam-Si merged 4 commits into
mainfrom
fix/bazel-sandbox-mount-failure

Conversation

@Sam-Si

@Sam-Si Sam-Si commented May 9, 2026

Copy link
Copy Markdown
Owner

The --test_tmpdir=/tmp/bazel-test-logs setting conflicts with --sandbox_tmpfs_path=/tmp because the tmpfs overlay mounts a fresh empty filesystem over /tmp inside the sandbox, causing the bind-mount of TEST_TMPDIR to fail with 'No such file or directory'.

This was preventing ALL tests from running — they were killed by the sandbox infrastructure before the test binary could even start.

Removing --test_tmpdir lets Bazel use its default TEST_TMPDIR handling, which is sandbox-compatible.

Sam-Si added 4 commits May 9, 2026 16:09
The --test_tmpdir=/tmp/bazel-test-logs setting conflicts with
--sandbox_tmpfs_path=/tmp because the tmpfs overlay mounts a fresh
empty filesystem over /tmp inside the sandbox, causing the bind-mount
of TEST_TMPDIR to fail with 'No such file or directory'.

This was preventing ALL tests from running — they were killed by the
sandbox infrastructure before the test binary could even start.

Removing --test_tmpdir lets Bazel use its default TEST_TMPDIR handling,
which is sandbox-compatible.
When a previous build/test is interrupted (Ctrl+C, OOM kill, crash),
Bazel's sandbox directories aren't cleaned up. The next run fails with
'Could not copy inputs into sandbox: ... (File exists)'.

Using --sandbox_base=/dev/shm places sandbox directories on tmpfs,
which is auto-cleaned on container restart and eliminates stale state
accumulation. This also improves sandbox I/O performance since /dev/shm
is memory-backed.
The previous approach (--sandbox_base=/dev/shm) failed because Docker
containers default to 64MB /dev/shm, which is too small for linking
large C++ binaries (Bus error + No space left on device).

Instead, handle stale sandbox state by:
1. Purging .bazel/output_base/sandbox in dcodex-setup.sh before builds
   (instant, preserves disk cache for fast incremental builds)
2. Documenting in .bazelrc why --sandbox_base=/dev/shm must NOT be used

This combined with the --test_tmpdir removal (previous commit) fixes
all known sandbox infrastructure failures.
Now that sandbox issues are resolved, the per-action debug traces
(thousands of lines per build) are no longer needed and drown the
actual test output. Can still be passed manually when needed:
  bazel test --sandbox_debug ...
@Sam-Si Sam-Si merged commit 4d40608 into main May 10, 2026
3 checks passed
@Sam-Si Sam-Si deleted the fix/bazel-sandbox-mount-failure branch May 10, 2026 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant