Prevent Windows test PATH leaks into User PATH - #103
Conversation
Ignored setup-nu acceptance tests call persist_path_dir, which writes the Windows User PATH via PowerShell. PathRestoreGuard only restored the process PATH, leaving Temp\.tmp*\off and existing-nu fixtures behind. Block durable PATH writes while the guard is held, restore User PATH on drop, and refuse persisting directories under the system temp folder. Co-authored-by: Anthony Thompson <github@trackdub.com>
|
Warning Review limit reached
Next review available in: 47 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe change isolates persistent PATH updates during tests, rejects system-temporary directories from PATH persistence on Windows and Unix, and documents cleanup guidance for existing PATH entries. ChangesPATH persistence isolation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 8✅ Passed checks (8 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
✨ Simplify code
Warning Review ran into problems🔥 ProblemsLinked repositories: Public OSS repositories can only analyze public repositories installed in this organization. Analyzed Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/nu/bootstrap.rs`:
- Around line 603-610: Update path_is_under_temp_dir so failure to canonicalize
the system temporary directory does not return false; apply the same
lexical-prefix fallback used in the dir.canonicalize failure branch, or
otherwise fail closed. Ensure persist_path_dir still refuses paths under the
temporary root, and add a regression test covering an uncanonicalizable
temporary root.
In `@src/util/test_paths.rs`:
- Around line 114-130: Update read_windows_user_path to distinguish command
failure, an absent User PATH, and an explicitly empty value by using an
unambiguous PowerShell output marker or snapshot representation. Update the
restoration logic in Drop to pass $null to SetEnvironmentVariable for an absent
original value, while preserving empty-string restoration for an explicitly
empty value. Add Windows tests covering both absent and empty User PATH
snapshots.
- Around line 56-68: Update PathRestoreGuard::new to capture the pre-existing
NUMAN_TEST_NO_PERSIST_USER_PATH value before setting it, then update its Drop
implementation to restore that value or remove the variable only when it was
originally absent. Preserve the current test-only flag behavior while the guard
is active.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 77e92cbf-1caa-4338-8801-a21c06537b14
📒 Files selected for processing (3)
CHANGELOG.mdsrc/nu/bootstrap.rssrc/util/test_paths.rs
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
tonythethompson/QuickShell(manual)tonythethompson/numan(manual)tonythethompson/dependency-chain-substrate(manual)
📜 Review details
⏰ Context from checks skipped due to timeout. (3)
- GitHub Check: Test (windows-latest)
- GitHub Check: Real-Nu acceptance (windows-latest)
- GitHub Check: Analyze (rust)
🧰 Additional context used
📓 Path-based instructions (11)
**/*
📄 CodeRabbit inference engine (CLAUDE.md)
**/*: Use Serena's semantic, symbol-aware tools as the primary tools for reading and editing code; use built-in Read, Glob, Grep, and Edit only under the stated exceptions.
Before editing a code file, inspect its symbol overview, read the specific symbols being changed, and edit them with Serena's symbol-aware tools.
Understand the existing code before changing it and make the smallest change that satisfies the request; avoid unrelated cleanup, premature abstractions, unnecessary error handling, feature flags, and compatibility shims.
Prefer editing existing files over creating new ones, and never create Markdown or README files unless explicitly requested.
For exploratory questions, provide a 2–3 sentence recommendation with the main tradeoff and do not implement until the user agrees.
For UI or frontend changes that cannot be tested in a browser, explicitly state that browser testing was not performed rather than claiming success.
Address security issues when discovered, including injection, XSS, SQL injection, path traversal, and secret leaks.
Pause and obtain confirmation before destructive, hard-to-reverse, externally visible, or third-party-upload actions, including deleting files or branches, dropping tables, force-pushing, modifying CI/CD, posting externally, or uploading content.
When blocked, investigate the root cause instead of bypassing it with --no-verify, --force, or deletion; investigate unfamiliar files, branches, and configuration before deleting them.
Only commit when explicitly asked; do not proactively update git configuration or push changes.
Do not skip Git hooks unless explicitly asked; if a pre-commit hook fails, fix the issue, re-stage, and create a new commit rather than amending.
Stage files by name rather than using git add -A or git add ., to avoid accidentally including secrets or large binaries.
Use a HEREDOC for commit messages, and add co-author attribution only when the user explicitly requests the exact trailer.
Do not force-pus...
Files:
CHANGELOG.mdsrc/util/test_paths.rssrc/nu/bootstrap.rs
!**/.env,!**/credentials.json,!**/*.pem
📄 CodeRabbit inference engine (CLAUDE.md)
Do not commit files that appear to contain secrets, including .env, credentials.json, and PEM files; warn before doing so even if explicitly requested.
Files:
CHANGELOG.mdsrc/util/test_paths.rssrc/nu/bootstrap.rs
**/*.{rs,md}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Match existing naming, module layout, and documentation level in the file being edited; update
AGENTS.md,docs/, or command help when structure, conventions, or user-visible behavior changes.Tests must cover failure modes, not only successful execution.
Files:
CHANGELOG.mdsrc/util/test_paths.rssrc/nu/bootstrap.rs
**/*.{rs,md,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Use the repository's established serialization and module conventions rather than introducing unrelated refactors.
Files:
CHANGELOG.mdsrc/util/test_paths.rssrc/nu/bootstrap.rs
**/*.md
📄 CodeRabbit inference engine (REVIEW.md)
Update documentation and
AGENTS.mdwhen project structure or conventions change.
Files:
CHANGELOG.md
**/*.{js,jsx,ts,tsx,py,java,go,rs,rb,php,c,cpp,h,hpp,cs,swift,kt,kts}
📄 CodeRabbit inference engine (CLAUDE.md)
Add comments only when the WHY is non-obvious; do not narrate what the code does, reference the current task, or reference the PR in comments.
Files:
src/util/test_paths.rssrc/nu/bootstrap.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/*.rs: Use the Rust 2021 edition.
Useanyhow::Resultwith.context(...)in application code; usethiserrorfor library error types that callers match on.
Useclapderive macros for CLI definitions.
Useserdewithserde_jsonortomlfor serialization.
Function parameters must use&Path, not&PathBuf.
Library code must not panic; error paths should returnanyhow::Resultwith context where appropriate.
Add or update tests for behavior changes, including relevant failure paths.
New mutating code paths must acquire the mutation lock viaacquire_mutation_lock(root)and snapshot the lockfile before writes.
Lockfile, journal, and state-file JSON writes must usewrite_json_atomic.
numan installmust write only to$NUMAN_ROOT; it must not invoke Nu or register plugins/autoloads.
Onlyactivateanddeactivatemay modify Nu integration state.
Treat the lockfile as the authoritative source of truth; derived projections such as autoload state must not be authoritative.
Install payloads under versioned, content-addressed paths and never overwrite them in place.
Never overwrite foreign autoload files; respectOWNERSHIP_MARKER.
Pass plugin paths through environment variables only; do not use runtime interpolation in Nu program strings.
**/*.rs: All CI gates must pass:cargo test,cargo clippy -- -D warnings, andcargo fmt --check.
Every mutating command—includinginstall,remove,update,gc, and futurenupm import—must callacquire_mutation_lock(root).
Lockfiles, journals, and state files must usewrite_json_atomic; partial writes are not allowed.
Pending activation, autoload, and lifecycle journals must be stored under$NUMAN_ROOT/state/.
Module autoload identity must match all four fields: Nu executable hash, Nu version, vendor autoload directory, and managed file path; the lockfilemodule_activationvalue is authoritative.
Never overwrite foreign autoload files; respectOWNERSHIP_MARKER.
Pass paths to Nu only throu...
Files:
src/util/test_paths.rssrc/nu/bootstrap.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Run and keep
cargo fmt/rustfmtclean, and ensurecargo clippy -- -D warningspasses.
Files:
src/util/test_paths.rssrc/nu/bootstrap.rs
**/*.{rs,nu}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/*.{rs,nu}: Real-Nu acceptance tests must be marked#[ignore]and should be run when changes affect activation or nupm import; unit tests must not spawn realnuand should use injectable seams such asFakeCandidateRunneror registrars.
The nupm integration must be read-only towardNUPM_HOME, must not executebuild.nu, and must not perform bidirectional synchronization.Unit tests must use
FakeCandidateRunneror injectable registrars and must not spawn a realnuprocess.
Files:
src/util/test_paths.rssrc/nu/bootstrap.rs
src/**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
Use
anyhow::Resultfor application code,thiserrorfor library error types, add context with.context(...)or?, and never panic in library code.
Files:
src/util/test_paths.rssrc/nu/bootstrap.rs
src/nu/**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
Managed Nushell files must contain
OWNERSHIP_MARKER; useassert_managed_file_ownedto prevent overwriting foreign files.
Files:
src/nu/bootstrap.rs
🔍 Remote MCP GitHub Copilot
Additional review context
- The PR is
#103, an open draft with one commit, three changed files, and+153/-1. No review threads were returned. persist_user_path(Windows) andregister_existing_nuboth ultimately callpersist_path_dir, so the new guard covers installed and off-path registration flows.- Ignored real-Nu acceptance tests use
PathRestoreGuard; the documented command iscargo test -- --ignored. PathRestoreGuardsetsNUMAN_TEST_NO_PERSIST_USER_PATH, snapshots User PATH through PowerShell, and restores it on drop. However:- It unconditionally removes the environment variable instead of restoring any pre-existing value.
- If the User PATH snapshot fails, restoration is skipped after only a warning.
path_is_under_temp_dirfails open when the system temp directory itself cannot be canonicalized.
- CI results currently show Linux/macOS tests, formatting, Clippy, packaging, MSRV, and CodeFactor passed; Windows test and Windows Real-Nu acceptance jobs were still in progress, while CodeQL was neutral.
🔇 Additional comments (2)
CHANGELOG.md (1)
12-18: LGTM!src/nu/bootstrap.rs (1)
1138-1154: 🩺 Stability & AvailabilityWait for all required Rust gates before merge.
Merge block is still in place while Windows test and Windows Real-Nu acceptance jobs are not showing completed success. Ship only after
cargo test,cargo clippy -- -D warnings, andcargo fmt --checkpass for this PR.
There was a problem hiding this comment.
Sorry @tonythethompson, you have reached your weekly rate limit of 500000 diff characters.
Please try again later or upgrade to continue using Sourcery
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
PR Summary by QodoPrevent Windows acceptance tests from persisting temp dirs into User PATH
AI Description
Diagram
High-Level Assessment
Files changed (3)
|
Greptile SummaryThe PR prevents acceptance tests from making durable User PATH or shell-profile changes while
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the prior stale Windows PATH restoration, Unix persistence bypass, and non-ASCII snapshot corruption paths have been removed or guarded.
|
| Filename | Overview |
|---|---|
| src/util/test_paths.rs | Replaces Windows User PATH snapshot restoration with a scoped persistence-suppression flag while preserving process PATH restoration and prior flag values. |
| src/nu/bootstrap.rs | Honors the test suppression flag across persistence paths and rejects temporary-directory binaries before durable PATH, profile, or symlink writes. |
| CHANGELOG.md | Documents the acceptance-test PATH leak fix and provides PowerShell cleanup instructions for existing entries. |
Reviews (7): Last reviewed commit: "Merge branch 'master' into cursor/fix-wi..." | Re-trigger Greptile
Code Review by Qodo
1.
|
Fail closed when the system temp root cannot be canonicalized, distinguish absent vs empty Windows User PATH on snapshot/restore, and restore any pre-existing NUMAN_TEST_NO_PERSIST_USER_PATH value from PathRestoreGuard. Co-authored-by: Anthony Thompson <github@trackdub.com>
Describe the no-persist flag and fail-closed temp refuse instead of implying registry User PATH restore. Co-authored-by: Anthony Thompson <github@trackdub.com>
Inline the PowerShell cleanup snippet so users do not need the PR. Co-authored-by: Anthony Thompson <github@trackdub.com>
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/util/test_paths.rs (2)
85-85: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winMake the formatting gate pass before merge.
Current CI reports
Format failed. Runcargo fmt --all, commit the formatter changes, and reruncargo fmt --check. Do not treat this change as ready while the required Rust formatting gate is red.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/util/test_paths.rs` at line 85, Run cargo fmt --all to apply the repository’s Rust formatting, commit all resulting formatter changes, and rerun cargo fmt --check to confirm the formatting gate passes before merge.Sources: Coding guidelines, MCP tools
76-76: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy liftImplement the promised User PATH restoration.
PathRestoreGuardrestores only the process-localPATHand removes the test flag. It does not snapshot or restore the Windows User PATH registry value. The suppliedpersist_path_dir_refuses_temp_directoriestest removes the flag while the guard is held, so a future non-temporary write could survive teardown.Snapshot the User PATH at construction and restore it in
Drop. Preserve the difference between an absent value and an empty value. Add Windows tests for both states. If prevention without restoration is the intended contract, update the objective and verify every User PATH write path remains blocked while the guard is held.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/util/test_paths.rs` at line 76, Update PathRestoreGuard to snapshot the Windows User PATH registry value during construction and restore it in Drop, preserving the distinction between an absent value and an explicitly empty value; add Windows tests covering both states and retain cleanup of NUMAN_TEST_NO_PERSIST_USER_PATH.Source: MCP tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In `@src/util/test_paths.rs`:
- Line 85: Run cargo fmt --all to apply the repository’s Rust formatting, commit
all resulting formatter changes, and rerun cargo fmt --check to confirm the
formatting gate passes before merge.
- Line 76: Update PathRestoreGuard to snapshot the Windows User PATH registry
value during construction and restore it in Drop, preserving the distinction
between an absent value and an explicitly empty value; add Windows tests
covering both states and retain cleanup of NUMAN_TEST_NO_PERSIST_USER_PATH.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: d117bc1c-26c1-4226-9655-30a4122ac2e4
📒 Files selected for processing (1)
src/util/test_paths.rs
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
tonythethompson/QuickShell(manual)tonythethompson/numan(manual)tonythethompson/dependency-chain-substrate(manual)
📜 Review details
⏰ Context from checks skipped due to timeout. (4)
- GitHub Check: Greptile Review
- GitHub Check: Real-Nu acceptance (windows-latest)
- GitHub Check: Test (windows-latest)
- GitHub Check: Analyze (rust)
🧰 Additional context used
📓 Path-based instructions (9)
**/*
📄 CodeRabbit inference engine (CLAUDE.md)
**/*: Use Serena's semantic, symbol-aware tools as the primary tools for reading and editing code; use built-in Read, Glob, Grep, and Edit only under the stated exceptions.
Before editing a code file, inspect its symbol overview, read the specific symbols being changed, and edit them with Serena's symbol-aware tools.
Understand the existing code before changing it and make the smallest change that satisfies the request; avoid unrelated cleanup, premature abstractions, unnecessary error handling, feature flags, and compatibility shims.
Prefer editing existing files over creating new ones, and never create Markdown or README files unless explicitly requested.
For exploratory questions, provide a 2–3 sentence recommendation with the main tradeoff and do not implement until the user agrees.
For UI or frontend changes that cannot be tested in a browser, explicitly state that browser testing was not performed rather than claiming success.
Address security issues when discovered, including injection, XSS, SQL injection, path traversal, and secret leaks.
Pause and obtain confirmation before destructive, hard-to-reverse, externally visible, or third-party-upload actions, including deleting files or branches, dropping tables, force-pushing, modifying CI/CD, posting externally, or uploading content.
When blocked, investigate the root cause instead of bypassing it with --no-verify, --force, or deletion; investigate unfamiliar files, branches, and configuration before deleting them.
Only commit when explicitly asked; do not proactively update git configuration or push changes.
Do not skip Git hooks unless explicitly asked; if a pre-commit hook fails, fix the issue, re-stage, and create a new commit rather than amending.
Stage files by name rather than using git add -A or git add ., to avoid accidentally including secrets or large binaries.
Use a HEREDOC for commit messages, and add co-author attribution only when the user explicitly requests the exact trailer.
Do not force-pus...
Files:
src/util/test_paths.rs
**/*.{js,jsx,ts,tsx,py,java,go,rs,rb,php,c,cpp,h,hpp,cs,swift,kt,kts}
📄 CodeRabbit inference engine (CLAUDE.md)
Add comments only when the WHY is non-obvious; do not narrate what the code does, reference the current task, or reference the PR in comments.
Files:
src/util/test_paths.rs
!**/.env,!**/credentials.json,!**/*.pem
📄 CodeRabbit inference engine (CLAUDE.md)
Do not commit files that appear to contain secrets, including .env, credentials.json, and PEM files; warn before doing so even if explicitly requested.
Files:
src/util/test_paths.rs
**/*.rs
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/*.rs: Use the Rust 2021 edition.
Useanyhow::Resultwith.context(...)in application code; usethiserrorfor library error types that callers match on.
Useclapderive macros for CLI definitions.
Useserdewithserde_jsonortomlfor serialization.
Function parameters must use&Path, not&PathBuf.
Library code must not panic; error paths should returnanyhow::Resultwith context where appropriate.
Add or update tests for behavior changes, including relevant failure paths.
New mutating code paths must acquire the mutation lock viaacquire_mutation_lock(root)and snapshot the lockfile before writes.
Lockfile, journal, and state-file JSON writes must usewrite_json_atomic.
numan installmust write only to$NUMAN_ROOT; it must not invoke Nu or register plugins/autoloads.
Onlyactivateanddeactivatemay modify Nu integration state.
Treat the lockfile as the authoritative source of truth; derived projections such as autoload state must not be authoritative.
Install payloads under versioned, content-addressed paths and never overwrite them in place.
Never overwrite foreign autoload files; respectOWNERSHIP_MARKER.
Pass plugin paths through environment variables only; do not use runtime interpolation in Nu program strings.
**/*.rs: All CI gates must pass:cargo test,cargo clippy -- -D warnings, andcargo fmt --check.
Every mutating command—includinginstall,remove,update,gc, and futurenupm import—must callacquire_mutation_lock(root).
Lockfiles, journals, and state files must usewrite_json_atomic; partial writes are not allowed.
Pending activation, autoload, and lifecycle journals must be stored under$NUMAN_ROOT/state/.
Module autoload identity must match all four fields: Nu executable hash, Nu version, vendor autoload directory, and managed file path; the lockfilemodule_activationvalue is authoritative.
Never overwrite foreign autoload files; respectOWNERSHIP_MARKER.
Pass paths to Nu only throu...
Files:
src/util/test_paths.rs
**/*.{rs,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Run and keep
cargo fmt/rustfmtclean, and ensurecargo clippy -- -D warningspasses.
Files:
src/util/test_paths.rs
**/*.{rs,nu}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
**/*.{rs,nu}: Real-Nu acceptance tests must be marked#[ignore]and should be run when changes affect activation or nupm import; unit tests must not spawn realnuand should use injectable seams such asFakeCandidateRunneror registrars.
The nupm integration must be read-only towardNUPM_HOME, must not executebuild.nu, and must not perform bidirectional synchronization.Unit tests must use
FakeCandidateRunneror injectable registrars and must not spawn a realnuprocess.
Files:
src/util/test_paths.rs
**/*.{rs,md}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Match existing naming, module layout, and documentation level in the file being edited; update
AGENTS.md,docs/, or command help when structure, conventions, or user-visible behavior changes.Tests must cover failure modes, not only successful execution.
Files:
src/util/test_paths.rs
**/*.{rs,md,toml}
📄 CodeRabbit inference engine (CONTRIBUTING.md)
Use the repository's established serialization and module conventions rather than introducing unrelated refactors.
Files:
src/util/test_paths.rs
src/**/*.rs
📄 CodeRabbit inference engine (AGENTS.md)
Use
anyhow::Resultfor application code,thiserrorfor library error types, add context with.context(...)or?, and never panic in library code.
Files:
src/util/test_paths.rs
🔍 Remote MCP DeepWiki, GitHub Copilot
Additional review context
- The PR diff does not implement User PATH snapshot/restoration, despite the PR description claiming it does.
PathRestoreGuardonly sets/removesNUMAN_TEST_NO_PERSIST_USER_PATHand restores the processPATH; no registry snapshot or restoration is present. PathRestoreGuardis used by tests insrc/nu/paths.rs,src/cmd/setup.rs,src/cmd/doctor.rs, andtests/setup_nu_test.rs, so the environment flag affects multiple test paths.persist_path_diris the shared persistence entry point for PATH updates, including Windows User PATH handling.- Current CI reports Format failed, while Clippy, MSRV, Linux tests, packaging, and CodeFactor passed. Windows and macOS test jobs were still running at retrieval time.
- DeepWiki could not locate the repository files or symbols needed for architectural analysis, so it provided no additional repository-grounded context.
🔇 Additional comments (3)
src/util/test_paths.rs (3)
50-62: Restore the prior test-flag value.
Dropstill removesNUMAN_TEST_NO_PERSIST_USER_PATHunconditionally. Save its value beforePathRestoreGuard::newchanges it, then restore that value or remove the variable only when it was initially absent.Also applies to: 76-76
8-12: LGTM!
38-38: LGTM!
Snapshot and restore the User PATH registry value on Windows, distinguishing absent ($null) from an explicit empty string, while still restoring the NUMAN_TEST_NO_PERSIST_USER_PATH flag across Drop. Co-authored-by: Anthony Thompson <github@trackdub.com>
Skip ~/.local/bin/nu symlink and shell-profile writes when NUMAN_TEST_NO_PERSIST_USER_PATH is set, and refuse tempfile-rooted binaries without the flag for parity with persist_path_dir. Co-authored-by: Anthony Thompson <github@trackdub.com>
Document that the test no-persist flag also skips ~/.local/bin/nu and shell-profile writes. Co-authored-by: Anthony Thompson <github@trackdub.com>
Encode PowerShell snapshots as Base64(UTF-8) instead of indexing a UTF-8 string with PowerShell's UTF-16 Length, which could truncate or panic. Co-authored-by: Anthony Thompson <github@trackdub.com>
SetEnvironmentVariable with an empty string deletes the User Path value, and empty process env vars collapse to $null in PowerShell. Write empty Value snapshots via an empty REG_SZ so they stay distinct from Absent. Co-authored-by: Anthony Thompson <github@trackdub.com>
Full registry snapshot restore could overwrite legitimate User PATH edits made while a guarded test ran. Rely on NUMAN_TEST_NO_PERSIST_USER_PATH and temp-path refusal to prevent durable test pollution instead. Co-authored-by: Anthony Thompson <github@trackdub.com>
Summary
Yes: those
C:\Users\...\Temp\.tmp*\offand...\existing-nuentries are Numan leftovers, but from Windows acceptance tests (cargo test -- --ignoredcoveringnuman setup nu use), not from a normal managednuman setup nuinstall.setup nu usecallspersist_path_dir, which writes the Windows User PATH via PowerShell. Tests previously left tempfile fixture dirs permanently when that path ran without a durable-write block. On Unix,persist_user_pathcould still create~/.local/bin/nuand update a shell profile whilePathRestoreGuardwas held.Fix
PathRestoreGuardsetsNUMAN_TEST_NO_PERSIST_USER_PATHwhile held and restores any pre-existing value of that flag on drop (or removes it only when it was originally absent)persist_path_dirand Unixpersist_user_pathhonor the test flag and refuse paths under the system temp folder (fail closed when temp canonicalize fails)Cleanup
PowerShell cleanup is documented in
CHANGELOG.mdunder Unreleased.Test plan
cargo test --lib util::test_pathscargo test --lib nu::bootstrapcargo clippy -- -D warningscargo fmt --all --check