I was installing the libv8 gem (which is ~512M) from rubygems and wondered why it was taking so long. This...
gem specification -r libv8
... gave me nothing about the size of the gem. Then I looked in the docs, and it looks like the gem creator has the option of putting information about the size of their gem under one of rubygems's pre-defined "optional gemspec attributes".
Q: So one can't reliably know the size of a remote gem before one installs it?
Bonus question: Would it be impractical to make gem size a required gemspec attribute?
Here is a terrible way to do it on OS X or Linux:
curl -s https://rubygems.org/api/v1/gems/<gem-name>.yaml | sed -n "s/gem_uri: //p" | xargs curl -sLI | grep -i Content-Length | tail -1
will give you the size (in bytes).
explanation:
use curl and the rubygems api to get some info about the gem:
curl -s https://rubygems.org/api/v1/gems/thor.yaml
get the URL for the gem file download
sed -n "s/gem_uri: //p"
download the response header for the gem (following redirects)
xargs curl -sLI
show only the last instance of 'Content-Length', case insensitive
grep -i Content-Length | tail -1
result (~82k):
Content-Length: 83456
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With