Restore the version a trial replaced - #17
Merged
Merged
Conversation
`trial:off` reinstalled whatever npm called latest, so ending a trial that started on 1.2.1 could hand back 1.3.0. A trial borrows the global install; it should give back the one it borrowed, not a different version chosen by whatever shipped meanwhile. `npm link` overwrites that install, so the version is read before the link and kept under `.trial/`. The probe reports which of three states it found: a version, a checkout already linked, or nothing installed. The first two are indistinguishable by version alone and only one has a version to come back to, and being told no published copy is installed when one is merely shadowed costs the pin for good. Ending a trial touches the global install only when there is something to hand back. A second `trial:off` finds no record, sees a registry install, and leaves it alone — reinstalling there would replace a version the developer chose with whatever is newest, which is the outcome this exists to prevent. A recorded value that is not a bare version is refused rather than installed, since `npm i -g <pkg>@<spec>` reads URLs, git refs and aliases from the same position. The completion cleanup reports what it cannot remove. Only the marked block is the script's to delete, so a reference to `.trial/completions` copied elsewhere in `.zshrc` survives it, and `.trial/` goes on the next line, leaving that `fpath` entry pointing at a directory that no longer exists. Naming the lines is the right amount of help; editing one the developer wrote is not the script's call. This tracks how tack and beacon end a trial: run the install path a user has rather than a parallel one, and land exactly what they would.
chris-peterson
force-pushed
the
restore-the-version-a-trial-replaced
branch
from
September 17, 2026 21:12
08bdc08 to
117e39c
Compare
chris-peterson
marked this pull request as ready for review
September 17, 2026 21:12
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.
Context
npm run trial:onputs a checkout on your PATH asgit fiso a change can be run for a few days before shipping. Ending the trial reinstalled@gettyimages/git-fiwith no version, which is whatever npm calls latest — so a trial started on 1.2.1 could hand back 1.3.0, and the developer is left on a version they never chose to install. A trial borrows the global install; it should give back the one it borrowed.trial:onnow records the installed version beforenpm linkoverwrites it, andtrial:offreinstalls that exact version.Review guide
The one thing to check — what counts as "a version to come back to":
scripts/trial.sh— a linked checkout and a registry install both report aversion, so the version alone can't tell them apart; the discriminator isresolved, which is afile:URL only for a link. Verified against the real global tree, which currently holds a link: the probe correctly returns empty. An absentresolved(some npm versions omit it for a registry install) reads as not-a-link, which is the right answer.Supporting:
scripts/trial.sh— where nothing was recorded, the latest is installed and the run says so. Silently leaving the developer with nogit fiat all would be the worse failure.scripts/trial.sh— only the marked block is the script's to delete, so a reference to.trial/completionscopied elsewhere in.zshrcsurvives it — and.trial/goes on the next line, leaving thatfpathentry pointing at nothing. It names the lines rather than editing one the developer wrote. This is live on at least one machine.SPEC.md— the two new requirements.Approach & trade-offs
trial:offstill needs the network, and that is not fixable here. tack and beacon end a trial with no network at all, because both install a wrapper in~/.local/binthat points at whichever copy they mean — so reverting is a local file write. git-fi can't take that shape:~/.local/binsits behind/opt/homebrew/binin a normal PATH, where npm links, so the wrapper would be shadowed. For an npm package the registry is the install path. Restoring the exact version is the part that was actually broken; removing the network round trip would mean changing how git-fi installs.Testing
npm test— 226 pass. Theinstalled_versionprobe was exercised against the real global tree in its linked state, which is the case thefile:check exists for; it returns empty, sotrial:offfrom here reports the no-recorded-version path rather than inventing a version.