Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An option to skip transitive dependencies when dumping #1489

Closed
ELLIOTTCABLE opened this issue Nov 6, 2024 · 3 comments
Closed

An option to skip transitive dependencies when dumping #1489

ELLIOTTCABLE opened this issue Nov 6, 2024 · 3 comments

Comments

@ELLIOTTCABLE
Copy link

ELLIOTTCABLE commented Nov 6, 2024

Would it be possible to dump only to dump "installed formulae that are not dependencies of another installed formula" just like brew leaves does?

This is already the case. brew leaves (as-is_ is not the right tool for the job here, though; just because something is a leaf does not mean you don't want it listed in your Brewfile. brew bundle effectively runs brew leaves --installed-on-request. If there's something being brew bundle dumpd that you don't want: it's because at some point you or some tool brew installed it.

To resolve this for your particular case e.g. libfido2 you should do something like:

brew uninstall --ignore-dependencies libfido2
brew install --only-dependencies mysql mysql-client

then, if my memory serves me correctly, it'll no longer brew bundle dump libfido2.

Originally posted by @MikeMcQuaid in #1260 (comment)

This was brought up previously, but closed, due to it not actually being a behaviour at the time. However, since then, it appears to be have been added as an intentional behaviour (i.e. brew bundle dump is currently including packages that do not appear in brew leaves - in fact, they're sorted non-alphabetically, before their leaf dependants, so it's pretty clear it's an intentional process.)

It'd be nice to be able to disable this behaviour optionally. Especially because there's no differentiation in the file between what was a leaf, and what was not; so that metadata is lost upon installation to a new system (or just ... existing for a couple of years, and forgetting what you've installed and why. 😅)

$ brew --version      
Homebrew 4.4.4-41-g451c3a8
Homebrew/homebrew-cask (git revision 7ee2e0d5f65; last commit 2024-11-05)
@MikeMcQuaid
Copy link
Member

Sorry, passing on this. This is intentional behaviour. Homebrew has no concept of leaves: only things installed on request or as dependencies. As mentioned previously: dependencies that are installed on request must be dumped earlier because they will be installed earlier and otherwise the error messages if they fail to install are unnecessarily confusing.

Especially because there's no differentiation in the file between what was a leaf, and what was not; so that metadata is lost upon installation to a new system

This metadata was never stored. What is installed on request, however, is not lost: it will still be installed on request on a new system and installed as a dependency when not specified in the Brewfile.

@MikeMcQuaid MikeMcQuaid closed this as not planned Won't fix, can't repro, duplicate, stale Nov 6, 2024
@ELLIOTTCABLE
Copy link
Author

ELLIOTTCABLE commented Nov 6, 2024

This metadata was never stored. What is installed on request, however, is not lost: it will still be installed on request on a new system and installed as a dependency when not specified in the Brewfile.

Wait, I'm confused; it's not lost?

As in, if I run one of the new brewfiles (that includes, say, brew "aom" before brew "imagemagick") on a new system, then brew leaves --installed-on-request won't print "aom"? Because that's my primary concern, polluting of the 'installed on request' list, which is a pretty crucial resource when working across a lot of languages, stacks, and projects, across multiple machines. 😅

@gromgit
Copy link
Member

gromgit commented Nov 7, 2024

I think @MikeMcQuaid's point is that if a formula appears in a Brewfile at all, that's because it's been marked as "installed on request", because that's the primary test used to curate the Brewfile contents in the first place.

So if brew "aom" is in your Brewfile, you either put it there manually, or it's been marked as "installed on request" on your system.

If I'm not mistaken, the relevant code is here:

def dump(describe: false, no_restart: false)
requested_formula = formulae.select do |f|
f[:installed_on_request?] || !f[:installed_as_dependency?]
end
requested_formula.map do |f|
brewline = if describe && f[:desc].present?
f[:desc].split("\n").map { |s| "# #{s}\n" }.join
else
""
end
brewline += "brew \"#{f[:full_name]}\""
args = f[:args].map { |arg| "\"#{arg}\"" }.sort.join(", ")
brewline += ", args: [#{args}]" unless f[:args].empty?
brewline += ", restart_service: true" if !no_restart && BrewServices.started?(f[:full_name])
brewline += ", link: #{f[:link?]}" unless f[:link?].nil?
brewline
end.join("\n")
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants