-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
brew info
should display download size
#18373
Comments
Here is a minimal way to find the total tarball sizes: for P in $(brew deps fastfetch)
do
brew cat "$P" | \
grep -m1 url | \
awk '{print $2}' | \
xargs wget -qO- | \
wc -c
done Note: tapping and downloading is required by the above for loop which (sort of) defeats the points, but this is merely a proof of concept. I think there should be a "size" field right below the |
That's a bit tricky since the bottle contains a copy of the formula, so changing the formula changes the size of the bottle too. That said, I think the bottle size (both compresses and uncompressed) is available in the annotations in the manifest, so in principle this should be straightforward to recover with Or, in a pinch, if you only care about compressed size: brew fetch foo
wc -c "$(brew --cache foo)" # bottle size
brew fetch --build-from-source foo
wc -c "$(brew --cache --build-from-source foo)" # source tarball size This makes it so that you don't need to download |
I agree. The size of bottle is what I was looking for rather than the tarballs.
That sounds like what I was looking for. Is there perhaps some sort of API that lets me "fetch" only the size, without first downloading the bottle? And |
Yes. The manifest can be fetched separately from the bottle. (In fact,
Yes, that's why you need to |
Where can I read more about getting only the manifest? I couldn't find it documented in https://docs.brew.sh. |
It's not documented, but you can see what
|
Now I'm thinking I perhaps should first work on a |
Seems to have a relatively niche/obscure use-case at the moment, so it's probably not a good fit. |
Ok. I'll see what I can do. Thx! |
One time I tried to install a calculator with
I think I'd personally benefit from brew calculating some kind of size for the operation (download size should be easy) and then giving the user a yes/no prompt if that size is large. |
I am no longer interested in solely working on a PR. It turned out to be more complicated than I expected as there is no API to fetch the download/install size. But happy to help. @umnikos if you (or someone else) are interested, lmk, and I will re-open the issue. Happy to help you debug too, just @ me. I will also consider working on this given enough thumbs up. Best proxy for interest I could find is a 2-year-old StackOverflow post with 7 upvotes: How to make Brew show the size of the formula before installing it?. That post also has workarounds that seem to no longer work but might be close enough. Most notably, it talks about the Bearer Token which is needed for |
@umnikos if you read the whole thread you'll see why this is not easy. If you disagree: we'd welcome said easy PR 😉
@osalbahr as mentioned by @carlocab above: said API is "download the manifest first and use that to figure out the size of the formula". The longer-term solution here would be to consider if we could e.g. download all these manifests daily and provide a JSON file of the rough sizes that could be incorporated into the formulae.brew.sh JSON API. I'd imagine ~24h outdated information here would be more useful than none at all. |
brew install
: Download/Install Sizebrew install
should display download size
I tried to work on that, but the path for going from Could you point me at the Ruby function that creates the |
It's not exactly what you're looking for but @cho-m opened a proof of concept PR (#18172) a couple weeks ago to add formula size information in |
I did have another related P.O.C. (local idea, not a PR) of creating a summed size. Mainly was experimenting with it as part of --- a/Library/Homebrew/install.rb
+++ b/Library/Homebrew/install.rb
@@ -284,17 +285,27 @@ module Homebrew
end
end
- if dry_run
+ if dry_run || prompt
if (formulae_name_to_install = formulae_to_install.map(&:name))
ohai "Would install #{Utils.pluralize("formula", formulae_name_to_install.count,
plural: "e", include_count: true)}:"
puts formulae_name_to_install.join(" ")
+ formulae = Set.new
formula_installers.each do |fi|
print_dry_run_dependencies(fi.formula, fi.compute_dependencies, &:name)
+ formulae.add(fi.formula)
+ formulae.merge(fi.compute_dependencies.flatten.map(&:to_formula))
end
+ installed_sizes = formulae.map { |f| f.bottle.installed_size }
+ ohai "Total size: #{disk_usage_readable(installed_sizes.sum)}" if installed_sizes.all?(&:positive?)
+ end
+ return if dry_run Anyway, will try to get around to my original PR first. Hopefully will have some more time. EDIT: Also, should now have more data to work with as all Sequoia bottles will have size information in manifest. Older versions won't. |
@cho-m awesome! Let me know if you'd like some help, feel free to @ me in the current or a new PR. We're not doing the exact same, but we can build off of a common ground. I like @MikeMcQuaid's idea of adding bottle sizes in JSON API. What is your current hack, and do you have a long-term plan? @apainintheneck thx for linking the related PR! |
Oh, @cho-m btw, how did you get Edit: ok, just realized it's a variable in the diff you pasted. I should probably read a Ruby book or do an online course |
@cho-m @osalbahr Note: if/when we're adding more information to the API here: it may be nice to also include |
brew install
should display download sizebrew info
should display download size
Since I am just learning Ruby, I think @cho-m what do you think? This is something I wanted to know today, just out of curiosity, on WSL (Ubuntu) $ brew info ruby
==> ruby: stable 3.3.5 (bottled), HEAD
Powerful, clean, object-oriented scripting language
https://www.ruby-lang.org/
Installed
/home/linuxbrew/.linuxbrew/Cellar/ruby/3.3.5 (19,856 files, 59MB) *
Poured from bottle using the formulae.brew.sh API on 2024-10-13 at 12:55:08
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/r/ruby.rb
License: Ruby
==> Dependencies
Build: autoconf ✘, pkg-config ✘, rust ✘
Required: libyaml ✔, openssl@3 ✔, gperf ✔, libffi ✔, libxcrypt ✔, zlib ✔
==> Options
--HEAD
Install HEAD version
==> Caveats
By default, binaries installed by gem will be placed into:
/home/linuxbrew/.linuxbrew/lib/ruby/gems/3.3.0/bin
You may want to add this to your PATH.
Emacs Lisp files have been installed to:
/home/linuxbrew/.linuxbrew/share/emacs/site-lisp/ruby
==> Analytics
install: 59,960 (30 days), 186,061 (90 days), 711,848 (365 days)
install-on-request: 22,271 (30 days), 74,546 (90 days), 313,322 (365 days)
build-error: 13 (30 days) |
@osalbahr Feel free to start with just that. |
I appreciate the green light. It lets me know that I am moving in the right direction. Though I don't mind if someone beats me to it. I created a repo learn Ruby. I will come back to adding the |
I am trying to add a line under I looked at $ brew info fastfetch | tail
==> Options
--HEAD
Install HEAD version
==> Caveats
Bash completion has been installed to:
/home/linuxbrew/.linuxbrew/etc/bash_completion.d
==> Analytics
install: 13,275 (30 days), 31,864 (90 days), 65,133 (365 days)
install-on-request: 13,275 (30 days), 31,864 (90 days), 65,133 (365 days)
build-error: 1 (30 days) |
That happens here: brew/Library/Homebrew/utils/analytics.rb Line 327 in ad9ea1c
Invoked from here in brew/Library/Homebrew/cmd/info.rb Line 360 in ad9ea1c
|
/start |
Verification
brew install wget
. If they do, open an issue at https://github.com/Homebrew/homebrew-core/issues/new/choose instead.Provide a detailed description of the proposed feature
I want to know the total download/install size when installing a package.
What is the motivation for the feature?
I am using a limited storage system (16 GB). Also boredom and I want to contribute to Homebrew again.
How will the feature be relevant to at least 90% of Homebrew users?
Sort of? It would be nice. But probably not needed. Storage is cheap. It will only affect people with pay-per-use data plans.
What alternatives to the feature have been considered?
brew deps
then somehow find tarball size for each package. This is good enough for my use.Example (only first step):
Then a bash for-each, since formula names are guaranteed to not have spaces (I think).
But would be nice if it's integrated into Homebrew under an undocumented flag. I would appreciate pointers on how to start this, such as existing open issues/discussions. Thx!
More info:
The text was updated successfully, but these errors were encountered: