Repository navigation
fix(install): a named install uses b.yaml; b.lock describes the file on disk - #195
Merged
Merged
Conversation
WriteLock set a new timestamp and tool version on every write, so every `b install` and `b update` changed b.lock even when no binary or env changed, and `git diff --exit-code b.lock` failed after any run. WriteLock now compares the binary and env entries with the file on disk. When they are the same, it leaves the file as it is. A changed entry writes the file with a new timestamp and tool version, as before. A missing b.lock is still written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`b install <name>` took the built-in preset and ignored the b.yaml entry of that name, so its version and file never applied; only the no-argument `b install` and `b install <name>@<version>` honoured a pinned version. GetBinary now looks up the b.yaml entry first and merges it over the preset with resolveBinary, the same merge as the no-argument install. An explicit @Version still wins. `b update <name>` and `b version <name>` use GetBinary too, so they now see the pinned version as well, like their no-argument forms. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`b install <name>@<version>` over a present binary of another version kept the old file and recorded its sha256 under the new version, so b.lock named one version and hashed another. Only --force replaced it. The install now decides per binary before any download (planInstall). A present file is kept when no version is asked for, or when b.lock says that file (by its sha256) is the version asked for. When another version is asked for, or b.lock does not describe the file, the binary is downloaded and replaced. A download that fails leaves the b.lock entry as it was, since the old file is still the one on disk. The onPost hook still runs only after a download. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A bare `b install <name>` over a present binary rewrote its b.lock entry with the version "" (the binary stayed). The entry took the version of the command line, which is empty when no version is asked for. When the install keeps the present file, the entry now records the version b.lock gives that file: the previous entry's version when its sha256 is the file's, else "" (b cannot tell which version the file is). An install that changes nothing now leaves b.lock as it was. With a version pinned in b.yaml, `b install <name>` asks for that version: a present file of it is kept, a file of another version is replaced. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The end-to-end install tests are !race, like the other tests that run an install through the progress writer, and the CI test jobs run with -race. planInstall and updateLock are now also tested without the progress writer, so the race job checks the keep-or-replace decision and the lock entry of a kept, a downloaded and a failed binary. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`b install <name>` for a b.yaml entry that is an alias of a preset cleared the entry's alias, so the binary went to the preset's file name and not to the name of the entry. Only --alias replaces it now. Also correct the comment on a failed download: the download writes the file in place, so a partial file can stay behind. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…eps its alias With the alias of a b.yaml entry kept, `b install <alias>@<version> --add` looked for the entry under the preset name, did not find it, and added a second entry of the same name. That entry replaced the first one, so its enforced version and its file were lost. addToConfig now looks for an aliased binary under its alias, the name a new entry gets. The named install of a provider-ref entry now also takes the entry's alias, as the no-argument install does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…is no preset - A provider-ref entry is stored under the ref, with the binary's name as its alias. `b install <ref>@<version> --add` and `b install --add` now update that entry; before, they added a second entry under the alias, which did not resolve. - GetBinary resolves a provider-ref entry as a provider ref, as the no-argument install does. A preset with the same name as the entry's alias no longer replaces the ref. - Tests: the provider-ref entry with and without an argument, the preset named like the alias, and the version update of an aliased entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- `--add` finds a provider-ref entry by the ref alone. With --alias, it
renames the binary in that entry; before, it added an entry under the
alias that did not resolve.
- A new provider-ref entry is written under the ref, with the alias as
the binary's name (`<ref>: {alias: t}`), the shape that the no-argument
install reads. An alias of a preset still gets its own entry, and the
entry of the preset's name stays as it was.
- Tests: --alias on a provider-ref entry (the entry keeps its other
fields), new entries of both kinds resolve to the files they installed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`b install jq@v2 --alias x --add` with an entry `jq: {file: /opt/jq}`
downloaded v2 into /opt/jq (the entry's file), then wrote an entry `x`
that names .bin/x. The file of a b.yaml entry belongs to that entry's
binary: --alias with another name now drops it for a preset. A provider
ref keeps its one entry, so it keeps the file too.
Tests: the installed file of both cases, the version of the new alias
entry, and the file of the entry that stays.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A preset installed under --alias is the binary of the b.yaml entry of
that name, the entry that --add writes. It now takes that entry's file,
or its own file when there is no such entry. Before, `--alias plain` on
an entry `plain: {file: /opt/plain}` installed .bin/plain while the
entry still named /opt/plain, and `--alias x` on an alias entry
`x: {file: /opt/x}` installed .bin/x.
Test: for its own name, an alias entry with a file and a new name, the
binary installs at the expected file and the written b.yaml resolves to
the same file.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An --alias that names the b.yaml entry of another binary (another preset's entry, an alias entry of another preset, or a provider ref's entry) made the install write over that binary's file and rewrite its entry. Complete now refuses it with a hint, and installs nothing. A new entry under --alias equal to the binary's own name no longer aliases itself. The condition in Complete is written without the negated conjunction (staticcheck QF1001). Tests: the alias table gets the refusals, an alias entry of the preset under the preset's own name, an alias entry under a new name, and a check that no written entry aliases itself. Mutants killed: the entry lookup also matching by alias, the provider-ref guard removed, the file reset removed, the check removed, a plain entry of any name accepted, the self alias. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
b.yaml `tool: {version: v1.0.0}` and `t2: {alias: tool, version:
v3.0.0}` install two files of one preset, but both wrote and read the
b.lock row of the preset's name. Each run then found the row of the
other file, and downloaded one binary again.
The row of a binary is now named by lockName: the alias for an alias
entry of a preset, the binary's name for the preset's own entry and
for a provider ref, as before. A b.lock written before still matches
the preset's own entry and every provider ref; an alias entry finds no
row once, and downloads its pinned version once. The digest checks of
b update read the row by the same name. b verify, which looks for the
file named by the row, now finds the default file of an alias entry.
Tests: three runs of `b install` over the two entries download 2, 0
and 0 binaries, each row describes its own file, and b verify passes;
a table of lockName. Mutants killed: the row read by the binary's
name, the row written by the binary's name, lockName without the alias,
lockName without the provider-ref guard.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With `x: {alias: plain, enforced: v3.0.0, file: /opt/x}`, `b install
plain --alias x --add` took the version and onPost of the entry plain:
it put plain's v1.0.0 into /opt/x and set the version of x to v1.0.0,
while the enforced pin of x stayed v3.0.0.
A preset installed under an --alias that names an entry of the same
preset is the binary of that entry. Complete now builds it from that
entry with resolveBinary, as the no-argument install does: version,
enforced pin, file and onPost. A version on the command line still
wins, and is now applied after the entry.
--add no longer sets the version of an entry to a value its enforced
pin contradicts (the pin wins at every later install, so the entry
would name a version b never installs). Such an install is refused
before any download, with a hint to add --fix, which moves the pin.
This also holds for an entry named directly, `b install x@v2.0.0 --add`.
The entry that --add writes is named by configKey, which addToConfig
and the check share.
Tests: the settings of the entry for six argument and alias pairs,
also when the preset's file is already set; the pin kept, refused or
moved with --fix; a table of checkPin. The alias-entry test of --add
no longer expects a version beside a contradicting pin. Mutants
killed: the entry not resolved, its file not applied, the command-line
version applied before the entry, the check removed, --fix ignored, the
pinned version refused, latest or an empty version refused, the check
by the binary's name, configKey without the alias or the ref.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`b install plain --alias tool` beside `github.com/org/tool: {alias:
tool}` was accepted and wrote over that ref's file, as the check looked
only for an entry named tool. A provider ref installed with --alias had
no check at all.
aliasOwner now finds the entry of another binary that --alias already
names: an entry of that name which is not an entry of the preset (for a
provider ref: any entry of that name), or a provider-ref entry, other
than the ref being installed, whose binary has that name (its alias, or
the name from the ref). Both a preset and a provider ref are refused
with the hint as before, and nothing is installed. entryOfPreset no
longer checks for a provider ref; aliasOwner does.
Tests: the alias of a ref, the name from a ref without an alias, a ref
under the alias of another ref, under a preset entry and under alias
entries; a ref under its own alias and under a new name is accepted.
The ref entries of the fixture now set IsProviderRef from the name, as
the loader does. Mutants killed: the check removed, the own-ref skip
removed, the ref entry's name or its binary name not compared, the name
from the ref dropped, any entry of that name not refused for a ref, a
plain entry of any name taken as the preset's.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…'s name The alias table had no case where the argument is an alias entry and --alias names an entry of the same preset, so a check of the argument's name in place of the preset's passed it. Two cases: `b install x --alias x` and `b install x --alias plain` (x an alias entry of plain) install at the file of the entry --alias names. Mutant killed (with this test alone): the alias check given the argument's name in place of the preset's. The fixture sets IsProviderRef as the loader does since the previous commit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`b install a b --alias x` gave both binaries the alias x, so both were installed into the one file of x, the last download winning. --alias names the file of one binary: Complete now refuses a second binary argument when --alias is set, with a hint, and installs nothing. An env install beside the one binary is still accepted, and several binaries without --alias too. The flag help says so. Test: two presets, a preset and a provider ref, a preset and an env install, one preset, and two presets without --alias. Mutants killed: the check removed, the check without the --alias condition, the check from the third binary on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
What
Four fixes to how
b installpicks a binary and records it inb.lock.b install <name>took the built-in preset first and ignored the b.yaml entry of that name.GetBinary(pkg/cli/shared.go) now looks up the b.yaml entry first and merges it withresolveBinary, the same merge the no-argumentb installuses. An explicit<name>@<version>still wins.b.lockthen recorded the asked version with the old file's hash.planInstall(pkg/cli/install.go) now decides per binary, before any download:--forceis set or the file is missing;latest), or when theb.lockentry's sha256 matches the file and its version is the one asked;b.lockwhen the entry describes the file, else"". It no longer records the command line's version or overwrites a known one with"". A failed download leaves the entry as it was.b.lockchanges only when an entry changes.WriteLockleaves the file as it is when the binary and env entries are the same, sotimestampandtool.bstay andgit diff b.lockstays clean after a no-op run.Behaviour changes (for the release notes)
b install <name>,b update <name>andb version <name>now see the b.yaml entry of that name (version, enforced, file, onPost), like their no-argument forms.b install <name>@<v>over a present binary of another version downloads and replaces it.b.lockdoes not confirm (no entry, or another sha256) is downloaded once. The no-argumentb install(the CI path) is included. After that download,b.lockmatches and the binary is kept.b.lock, includingtool.bfrom a newer b.Tests
pkg/lock:TestWriteLock_UnchangedEntriesKeepTheFile.pkg/cli:TestGetBinary_ConfigEntryOverPreset.TestPlanInstall(10 cases) andTestUpdateLock_FollowsThePlan. These run in the-raceCI job.install_pins_norace_test.go: Run-level tests against an httptest release server (replace, keep, failed download, config version).go test ./...andgo test -race ./pkg/cli/ ./pkg/lock/pass,go vetpasses, gofmt is clean, and golangci-lint v2.9.0 reports 0 issues.Note: the
!racetest files (including the existinginstall_norace_test.go) never run in CI, because the test jobs use-race. The plan tests cover the decision there. A non-race test step would also run the Run-level tests.Review rounds 1-5 (alias and
--add)--aliasis given.--addupdates an aliased entry in place, and keeps its enforced version and file.--addfinds it by the ref, and--aliasrenames the binary in it. A new ref entry is written as<ref>: {alias: x}.GetBinaryresolves a provider-ref entry as a ref. A preset with the same name as the alias does not replace it.Left open
GetBinaryandGetBinariesFromConfig(pre-existing).b update's own keep/replace logic is unchanged.--on-postand--assetare not written into an entry that already exists.b verifylooks forPATH_BIN/<lock row name>, so it reports an aliased binary as missing (also on main).🤖 Generated with Claude Code