fix: install without TMPDIR, keeping scratch in the user cache
The runner installer refused to start when TMPDIR was unset, which is the normal case for most shells, so onboarding would fail for real users (and did in CI). It now uses TMPDIR when set and otherwise the user's cache directory, so scratch stays on disk. All tests pass with TMPDIR unset.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+14
−4
internal/runner/setup/install.go+14 −4
CI passed — run details
Intent
diff --git a/internal/runner/setup/install.go b/internal/runner/setup/install.go| index 86eb38ce..a2f7be75 100644 |
| --- a/internal/runner/setup/install.go |
| +++ b/internal/runner/setup/install.go |
| @@ -77,11 +77,21 @@ func installUser(ctx context.Context, o InstallOptions, h installHost) (r Instal |
| if json.Unmarshal(raw, &m) != nil || m.Validate(o.Release) != nil { |
| return fail("runner.install.release") |
| } |
| - // Each attempt owns exactly one private scratch directory on the configured disk. |
| - if os.Getenv("TMPDIR") == "" { |
| - return fail("runner.install.scratch") |
| + // Each attempt owns exactly one private scratch directory. TMPDIR wins |
| + // when set; otherwise the user's cache directory keeps it on disk, since |
| + // /tmp may be a shared RAM disk. |
| + scratchRoot := os.Getenv("TMPDIR") |
| + if scratchRoot == "" { |
| + cache, ce := os.UserCacheDir() |
| + if ce != nil { |
| + return fail("runner.install.scratch") |
| + } |
| + scratchRoot = filepath.Join(cache, "equipo", "install") |
| + if os.MkdirAll(scratchRoot, 0o700) != nil { |
| + return fail("runner.install.scratch") |
| + } |
| } |
| - scratch, e := os.MkdirTemp(os.Getenv("TMPDIR"), "equipo-install-") |
| + scratch, e := os.MkdirTemp(scratchRoot, "equipo-install-") |
| if e != nil { |
| return fail("runner.install.scratch") |
| } |