Skip to content

feat(utils): MSB_HOME env override for isolated state#669

Open
toksdotdev wants to merge 3 commits intomainfrom
feat/msb-home-env
Open

feat(utils): MSB_HOME env override for isolated state#669
toksdotdev wants to merge 3 commits intomainfrom
feat/msb-home-env

Conversation

@toksdotdev
Copy link
Copy Markdown
Member

@toksdotdev toksdotdev commented May 5, 2026

summary

ci jobs that share a self-hosted runner also share ~/.microsandbox/ between runs, so a sandbox or sqlite migration left by one job can break the next. added an MSB_HOME env var that overrides the default home dir, letting each job point microsandbox at its own state without touching $HOME and clobbering everything else that reads it.

set per-job in the node sdk integration test workflow (the one currently flaking on SQLITE_BUSY / stale boot state):

env:
  MSB_HOME: ${{ runner.temp }}/msb-home-${{ github.run_id }}

$RUNNER_TEMP is wiped between jobs, so cleanup is automatic. test-utils::init_isolated_home was migrated to use the same env var, which let it drop the $HOME mutation and the bin/lib symlink dance.

test plan

  • cargo test --workspace
  • cargo check --workspace

toksdotdev added 2 commits May 5, 2026 10:20
`microsandbox_utils::resolve_home()` now checks `$MSB_HOME` before
falling back to `~/.microsandbox/`. lets ci jobs and integration
tests isolate per-process state (db, sandboxes, cache, logs) without
touching `$HOME` and clobbering tooling that lives there (npm cache,
ssh keys, etc.).

every prior call site that built `~/.microsandbox` from `dirs::home_dir()`
goes through the new helper: db init, config home resolution, setup
downloader, and the cli `self` subcommand.

set `MSB_HOME=$RUNNER_TEMP/msb-home` in ci to give each job a clean
microsandbox state directory.
drop the symlink dance and the unsafe `$HOME` mutation in
`init_isolated_home`. instead, point microsandbox at the test's tempdir
via the new `MSB_HOME` env var and reuse the real installed binary via
`MSB_PATH`. libkrunfw is resolved from `MSB_PATH`'s sibling lib dir, so
no per-test bin/lib mirroring is needed.

upsides:
- `$HOME` is left untouched, so other tooling that reads it (npm cache,
  ssh keys, etc.) keeps working
- ~30 LOC of `symlink_into` / `mirror_dir` plumbing gone
- the same env vars work for non-rust integration tests (node, python)
@toksdotdev toksdotdev requested a review from appcypher as a code owner May 5, 2026 14:23
isolates the node sdk smoke test job's microsandbox state (db,
sandboxes, cache) from any other job that runs on the same self-hosted
runner. fixes the flake where a sandbox or migration written by an
earlier job left state the next run couldn't reconcile.

`$RUNNER_TEMP` is wiped between jobs, so no manual cleanup is needed.
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