test(cli): the sandbox holds when CLAUDE_CONFIG_DIR is set - #251
Open
bdelanghe wants to merge 1 commit into
Open
test(cli): the sandbox holds when CLAUDE_CONFIG_DIR is set#251bdelanghe wants to merge 1 commit into
bdelanghe wants to merge 1 commit into
Conversation
Tests pin $HOME to a tempdir, which sandboxes every reader that derives its paths from it. The Claude reader does not derive from $HOME: since b31f2c5 it prefers $CLAUDE_CONFIG_DIR, which the child process inherits from whoever ran cargo. On a machine that exports it — every Claude Code user, since that variable is how a custom config root gets selected at all — the CLI walks out of the sandbox and reads the developer's real config, so the fixture session is reported missing. 28 of 29 failures on this box, none of them visible in CI, which exports no such variable: cargo test -p path-cli --test integration 20 failed cargo test -p path-cli --test query 8 failed env -u CLAUDE_CONFIG_DIR cargo test ... all pass Remove the variable where each suite already builds its sandboxed command, and in ScopedHome beside $HOME and $TOOLPATH_CONFIG_DIR. A test that wants to exercise the override can set it on its own command. One failure is left after this, and it is a different escape of the same shape: file_input_explicit_opencode_projects_and_records_exec follows $XDG_DATA_HOME to the real opencode database.
This was referenced Sep 1, 2026
|
🔍 Preview deployed: https://41a4bcfe.toolpath.pages.dev |
bdelanghe
marked this pull request as ready for review
September 1, 2026 18:33
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tests pin
$HOMEto a tempdir, which sandboxes every reader that derives its paths from it. The Claude reader does not derive from$HOME: since b31f2c5 it prefers$CLAUDE_CONFIG_DIR, and the child process inherits that from whoever rancargo.On a machine that exports it — every Claude Code user, since that variable is how a custom config root gets selected at all — the CLI walks straight out of the sandbox:
CI never sees this; it exports no such variable. Locally it is 28 failures:
The fix
Remove the variable in the three places each suite already builds its sandboxed command —
integration.rs'scmd(),query.rs'scmd()and its two directCommand::cargo_bincall sites — and inScopedHome, beside$HOMEand$TOOLPATH_CONFIG_DIR.Removed, not pinned: the point is to restore the reader's
$HOME-relative default so theHOMEthe test already sets is the one that counts.ScopedHomerestores the previous value on drop like the others. A test that wants to exercise the override sets it on its own command.After this, one failure remains — deliberately
file_input_explicit_opencode_projects_and_records_execstill fails. It is the same shape of escape through a different variable: the opencodePathResolverprefers$XDG_DATA_HOMEover$HOME, so it finds the developer's realopencode.db. The fix is a separate one-liner inScopedHome— it was #142, whose branch died with the fork; the commit survives as tagarchive/fork/fix-opencode-test-xdg-isolationand is a clean cherry-pick onto main.Kept out of this PR: different variable, different reader, its own review.
$CLAUDE_CONFIG_DIRescaping the test sandbox. Test files only, no production code.cargo test -p path-cli --test integration62/62 and--test query37/37, run withCLAUDE_CONFIG_DIRstill exported — the condition that previously failed.cargo test --workspacegoes from 29 failures to 1.cargo fmt --all --checkclean.$CLAUDE_CONFIG_DIR; the test harness sandboxes$HOMEonly, so the variable was inherited and outranked the sandbox. Confirmed byenv -uflipping every failure to a pass.ScopedHomefollows the save/restore pattern already there for$HOMEand$TOOLPATH_CONFIG_DIR.$XDG_DATA_HOMEescape is left failing for its own PRNeed help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.