-
-
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 install
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 |
@ZhongRuoyu thx! I figured out adding the placeholder. The next step would be figuring out how to get it from (or add it to) the JSON API. $ brew info fastfetch | tail -2
==> Size
Bottle size: 0 |
Is there anything left to do here? I think this has already been implemented. For example:
|
@carlocab what branch are you on? I don't see the Size lines on |
|
Not sure what is happening. $ brew --version
Homebrew 4.4.11-27-g9783ab0
Homebrew/homebrew-core (git revision 249e9860b75; last commit 2024-12-12)
$ brew info hello
==> hello: stable 2.12.1
Program providing model for GNU coding standards and practices
https://www.gnu.org/software/hello/
Conflicts with:
perkeep (because both install `hello` binaries)
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/h/hello.rb
License: GPL-3.0-or-later
==> Analytics
install: 11,230 (30 days), 14,692 (90 days), 33,990 (365 days)
install-on-request: 11,230 (30 days), 14,692 (90 days), 33,988 (365 days)
build-error: 18 (30 days) I double-checked that I don't have $ cd $(brew --repo)
$ git branch
info-size
* master
stable
$ git status
On branch master
nothing to commit, working tree clean |
What's the output of |
% brew config
HOMEBREW_VERSION: 4.4.11-27-g9783ab0
ORIGIN: https://github.com/Homebrew/brew
HEAD: 9783ab062cfcdc5ce776bfe5d163be3ee5fc7840
Last commit: 12 hours ago
Branch: master
Core tap HEAD: a39a029f686500517cc653fb5436d5a9ca50e52a
Core tap last commit: 53 minutes ago
Core tap JSON: 12 Dec 19:27 UTC
Core cask tap HEAD: 42778f1712c375cd3822b8223ade28c2545922b6
Core cask tap last commit: 55 minutes ago
Core cask tap JSON: 12 Dec 19:27 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 10
HOMEBREW_SORBET_RUNTIME: set
Homebrew Ruby: 3.3.6 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.3.6/bin/ruby
CPU: 10-core 64-bit arm_blizzard_avalanche
Clang: 16.0.0 build 1600
Git: 2.39.5 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 15.1.1-arm64
CLT: 16.1.0.0.1.1729049160
Xcode: N/A
Rosetta 2: false % brew doctor
Your system is ready to brew. |
Ah, I see what's going on. I've previously run Try doing |
There is still a goal of adding data to JSON API, though whoever works on this needs to make sure on any performance impact, e.g.
|
Yup, that was it. Is this intended behavior? |
Yes as fetching manifest adds a short but noticeable impact. Could consider adding an environment variable to make it default for users who are aware and willing to accept the extra network request. Ideally want to default to fastest/offline-capable |
brew info
should display download sizebrew install
should display download size
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: