List the built-in Homebrew sources and use tap names to add and remove sources - #5433
Open
awss (awss1i) wants to merge 1 commit into
Open
awss (awss1i) wants to merge 1 commit into
awss (awss1i) wants to merge 1 commit into
Conversation
…e sources Homebrew 4 and later serve homebrew/core and homebrew/cask from the API without a tap, so `brew tap` prints nothing for them and the sources page listed nothing: the default "Homebrew" source showed as not configured. Adding it ran `brew tap Homebrew <url>`, which brew rejects with "Invalid tap name: 'Homebrew'"; removing ran `brew untap Homebrew`. The source list now always starts with the built-in sources (the same known-source objects, so they count as configured) and adds every other tap from `brew tap`, skipping homebrew/core and homebrew/cask lines. "Homebrew Cask" is a known source on macOS only, since Homebrew on Linux has no casks. Add and remove map "Homebrew" and "Homebrew Cask" to homebrew/core and homebrew/cask; other sources are already named after their tap and keep the URL argument. The source names are unchanged, so the --cask decision and the installed-package sources are unaffected. Relates to Devolutions#5219
This branch has not been deployed
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.
On Linux (and on any Homebrew 4+ install), the Homebrew sources page is empty, "Homebrew" shows as not configured, and adding it fails with
Error: Invalid tap name: 'Homebrew', as Ed Kolis (@ekolis) reported in #5219. This PR lists the built-in sources that Homebrew serves without a tap and passes brew the tap names it expects.This covers the sources part of #5219 only. The headline, installed Homebrew packages missing under Distrobox, did not reproduce here with the reporter's steps (details below), so this PR does not claim to fix it and uses
Relates to.Why it happened
HomebrewSourceHelper.GetSources_UnSafeonly parsesbrew tap. Since Homebrew 4, homebrew/core and homebrew/cask come from the JSON API and are not tapped, sobrew tapprints nothing on a normal install and the list was empty.GetAddSourceParameters/GetRemoveSourceParameterspasssource.Nameas the tap. The known sources are named "Homebrew" and "Homebrew Cask", which brew never accepts as tap names.What changed
HomebrewSourceHelper:brew tapline;homebrew/coreandhomebrew/casklines are skipped so a developer who tapped them does not see duplicates. The list building moved intoBuildSourceListso it can be tested without brew; the URL guess for other taps is the existing code, moved.GetTapNamemaps "Homebrew" tohomebrew/coreand "Homebrew Cask" tohomebrew/cask; add runstap <tap>for those andtap <name> <url>for any other source as before; remove runsuntap <tap>.Homebrew.cs:KnownSourcescomes fromCreateBuiltInSources(this, OperatingSystem.IsMacOS()): "Homebrew" everywhere, "Homebrew Cask" on macOS only.DefaultSourceis unchanged.HomebrewPkgOperationHelper's--caskdecision and the installed/updates source lookups behave as before),HomebrewPkgOperationHelper.cs,HomebrewPkgDetailsHelper.cs, and the listing/update parsing.Verification
Fedora 44 host, a Fedora 44 distrobox (the reporter's setup) with Homebrew 7.0.6 and
hello,jqinstalled. Debug builds ofmain(d0d5165) and this branch, run--headlessinside the box and queried with the same binary. The brew calls in the table were recorded by a pass-throughbrewscript placed first on PATH, which the app picked as its brew.source list --manager homebrew(brew tapprints nothing)source add --name Homebrew --url https://github.com/Homebrew/homebrew-corebrew tap Homebrew https://github.com/Homebrew/homebrew-core: exit 1,Error: Invalid tap name: 'Homebrew'brew tap homebrew/core: exit 1,Error: Tapping homebrew/core is no longer typically necessary.(see the question below)source add --name hashicorp/tap --url https://github.com/hashicorp/homebrew-tapbrew tap hashicorp/tap <url>, exit 0source listafter thatsource remove --name hashicorp/tapbrew untap hashicorp/tap, exit 0package installed --manager homebrewbrew tap homebrew/coreandbrew tap homebrew/caskexit 1 without--force,brew untap homebrew/coreexits 1 ("No available tap"), andbrew taplists neither, which is why the built-ins are listed as present rather than added.UniGetUI.PackageEngine.Tests1255 to 1261 passed (6 new inHomebrewManagerTests: 3 facts on the source list and the platform split, a 3-row Theory on add/remove parameters); the 30 failures on Linux are the same pre-existing Windows-only ones onmainand here, compared by name. 5 consecutive runs ofHomebrewManagerTests, 7/7 each.homebrew/coreline fails 1; dropping the tap-name mapping fails the Homebrew and Homebrew Cask rows; offering casks on Linux fails 1. Each revert restored the files byte for byte (sha256 compared).dotnet testgive the same 1261 / 30.dotnet format whitespace src --folder --verify-no-changesanddotnet format style UniGetUI.Avalonia.slnx --no-restore --verify-no-changesclean.CreateBuiltInSources(isMacOS: true)only), and the Sources page in the GUI (synthetic input does not reach the window on my Wayland session; the CLI reads the sameGetSourcesthe page uses).The headline of #5219 did not reproduce
Following the reporter's 8 steps on a Fedora 44 host (not Bazzite) with a Fedora 44 distrobox, the UniGetUI rpm inside, Homebrew inside, the app exported and started with
distrobox-enter -n fedora-box -- /opt/unigetui/UniGetUI:package installed --manager homebrew(headless)brew list --formula --versionsreturns in under a second, far from the 60 s listing timeout. What differs from the report and I could not test: Bazzite as the host (as far as I know it can ship Homebrew on the host under /home/linuxbrew, which a box would share with a container-local install) and a first-run brew. Ed Kolis (@ekolis), if you can runbrew list --formula --versionsinside the box and share the output ofunigetui log manager --manager homebrew --verbosefrom the same box, that would show which of the two it is.A question for review
Adding the built-in "Homebrew" source by hand still reports "failed", now with brew's own reason, because brew refuses to tap homebrew/core without
--force. Since the source is now always listed as configured, I left it as an honest failure. The alternative is to treat adding a built-in as a success without calling brew; happy to switch if you prefer that.Review guide
HomebrewSourceHelper.cs:GetSources_UnSafenow only collects lines;BuildSourceListholds the old loop body unchanged apart from the two-line skip, plus the known sources up front.GetTapNameand the two parameter methods are the rest.Homebrew.cs: theKnownSourcesinitializer becameCreateBuiltInSources.HomebrewManagerTests.cs: 4 new tests after the existing one.Not in this PR
SourceManagerCardViewModel).libfontconfigbut notlibicu, so on a fresh Fedora box the binary stops with "Couldn't find a valid ICU package installed on the system" untildnf install libicu. Happy to open an issue for it.Relates to #5219