fix: repoint absolute env paths into the worktree - #19
Open
nemanull wants to merge 1 commit into
Open
Conversation
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.
fix: repoint absolute env paths into the worktree
Closes #18
The problem
wtbuilds a worktree's env files in three passes: copy each file verbatim fromthe main checkout, fill in vars missing from the committed example, then patch
the keys listed in
wt.config.json.That last pass only touches keys the config names. Everything else is inherited
byte-for-byte — including absolute paths that still address the main checkout.
A worktree that runs another checkout's build artifact looks completely healthy:
Only the code behind it is wrong. Every change you make in the worktree is not
what runs, so local verification of that component proves nothing.
The fix
For every absolute value in a seeded env file, find the git working tree that
encloses it by walking up for a
.gitentry (a directory in a primary checkout,a file in a linked worktree). Then:
/usr/bin/nodeis shared on purpose.No configuration and no key list. That is deliberate: an explicit list of path
keys is exactly what would have prevented this bug, and exactly what will fall
behind again the next time someone adds a key.
Why not just add the key to
wt.config.jsonThe issue suggests that as a companion change. It fixes one instance. An audit of
the repo that hit this found four more keys that break identically the moment
anyone makes them absolute — a RocksDB state directory, a cache directory whose
cleanup job deletes under it, a sync scratch directory, and a test impact graph.
All are relative today. None would be covered by a list nobody remembered to grow.
Scope
wt.config.jsonunderenvFilesare examined.CRLF line endings are written back verbatim.
PATH-style values and unterminated quotes are skipped whole,rather than half-repaired.
worktree is still recognised as the main worktree.
wt env seedis unchanged. It has no worktree to repoint paths at.Verifying
Reported to
stderr, and in--jsonunderenvPathEscapes:Run against three real worktrees of the repo that reported this: the two carrying
the escaped value each rewrite exactly one line, and the one a developer had
already hand-repaired is a no-op. No other line in a 132-line env file moves.
docs/env-path-isolation.mddocuments the failure mode, since a silently wrongbinary is indistinguishable from success in logs.
Repairing existing worktrees
Worktrees created before this still hold the escaped values. Re-run plain
wt setupinside one. Notewt setup --repairshort-circuits when there isnothing else to repair, so it will not do it.