When RubyGems hangs - ruby

I just had RubyGems not updating for a minute or two on "Fetching gem metadata from http://rubygems.org/".
I'm wondering how to prevent this in the future. Is there a reliable RubyGems mirror which I could specify as an additional source in Gemfile? And would it automatically switch over to the new source after a short timeout?

There is no official mirror. But I discovered that pointing your Gem source to http://production.s3.rubygems.org worked even when I got time-outs from http://rubygems.org

Related

Updating Gemfile.lock without installing gems

Is there a way to force an update of the Gemfile.lock without installing the gems that have changed?
Run bundle lock --update.
I found an answer in a blog post by Chris Blunt: “Rails on Docker: Quickly Create or Update Your Gemfile.lock”:
Today, I discovered a way to save the hours wasted downloading gems: bundler’s lock command.
This gem of a command resolves your app’s dependencies and writes out the appropriate Gemfile.lock – without installing any of the gems themselves.
According to the changelog, this command was added in Bundler 1.10.0.pre, released about eight months after this question was asked.
Instead of
bundle install
do the following:
bundle lock
This will just update the Gemfile.lock, but not attempt to install the files locally.
If you want to prepare a Gemfile.lock for a remote or deployment platform you must add it using
bundle lock --add-platform ...
Latest docs at https://bundler.io/v1.16/man/bundle-lock.1.html
UPDATE: This is still supported by the current (2.4) version but has been deprecated in favour of the lock command.
Force your specific requirement using:
bundle inject rmagick "=1.7.1"

How can I install the YR weather gem?

I am trying to install the yr.no weather api gem from here but am having problems adding the repository.
I tried gem sources -a http://irbno.rubyforge.org/ but this results in the following error:
Error fetching http://irbno.rubyforge.org/:
bad response Not Found 404 (http://irbno.rubyforge.org/specs.4.8.gz)
I am on Windows XP with Ruby 1.9.2 and have updated to the latest version of Rubygems (1.5.2)
ruby -v returns
`ruby 1.9.2p0 (2010-08-18) [i386-mingw32]`
whilst gem sources -l returns
*** CURRENT SOURCES ***
http://rubygems.org/
http://gemcutter.org
Any thoughts? Is this a problem with the repository or my setup?
The correct URI for the RubyForge RubyGems Repository was http://Gems.RubyForge.Org/, not http://IrBNo.RubyForge.Org/. However, the RubyForge RubyGems repository was shut down a long time ago and migrated to RubyGems.Org, so that URI is now simply a redirect to http://RubyGems.Org/ (as is http://GemCutter.Org/ BTW).
Since you already have that repository URI in your RubyGems sources, you don't need to do anything.
May I ask where you found the information that http://IrBNo.RubyForge.Org/ was the correct URI for the RubyForge RubyGems Repository? You should inform those people that their information is wrong (http://IrBNo.RubyForge.Org/ never was the URI of the RubyForge RubyGems Repository, it always was http://Gems.RubyForge.Org/) and outdated (the default RubyGems Repository moved to http://GemCutter.Org/ and then to http://RubyGems.Org/ a long time ago).
Not that any of this really matters, since as far as I can tell, there was never a Gem released for this project anyway.

Bundler can't find Ruby gem that appears on website

I installed Bundler on a pre-Rails 3 application and am trying to use it to install gems. My Gemfile contains the following lines:
source :rubygems
[...]
gem "RubyInline", "3.8.1"
However, when I run bundle install I get this error:
Fetching source index for http://rubygems.org/
Could not find gem 'RubyInline', required by 'memcache-client (= 1.6.3)', in any of the sources
The gem appears on the rubygems website:
http://rubygems.org/gems/RubyInline
Why is it giving me an error then?
I'm afraid this resolved itself after changes to fix other issues, and I'm not sure what the fix was. The source of several other issues was wrong permissions on various gems/binaries.
This kind of issue for me seems to be resolved on occasion by applying
bundle update
before
bundle install
The effect is to resolve old dependencies from when the bundle was originally produced and hence a gem that has been superseded (or whatever) will no longer be in the Gemfile.

not in gzip format error

while installing any Gem or doing any listing of gem gzip related error comes as shown below:-
C:\Documents and Settings\gangunra>gem install rhosync -v 2.0.0.beta7 --pre
ERROR: While executing gem ... (Zlib::GzipFile::Error)
not in gzip format
C:\Documents and Settings\gangunra>gem list rails -r
*** REMOTE GEMS ***
ERROR: While executing gem ... (Zlib::GzipFile::Error)
not in gzip format
Please help me out how to reslove this
Looks like rubygems.org (or any gem source you have defined) is down.
Not sure if your error was happening in tar_input.rb or ruby_core_source.rb.
Most people solved tar_input.rb error, by cleaning up cache files. I solved the one for ruby_core_source.rb:57 'initialize' : not in gzip format
and here is the description and workaround:
The problem was because "sometimes" the ruby source file in the ftp server is not probably tar + gzip. So sometimes the source file is incorrect.
I just gone through the source code, and the code expects a .tar.gz in the ftp server (e.g. http ://ftp.ruby-lang.org/pub/ruby/1.9/xxx.tar.gz). But the file found was only tar, but not gzip-ed.
The workaround is to modify the code in your gem directory.
I am looking for ppl who knows why the file hosted in ruby-lang.org is not properly gzip-ed. Hope that can solve forever.
Here is the detail description of my finding:
http://ru05team.blogspot.com/2011/08/solving-workaround-initialize-not-in.html
Here is the workaround, source code that you have to change:
https://gist.github.com/1183048
Make sure you are using the right Gem sources.
$ gem sources
should display http://rubygems.org/ as the first source.
If missing, add http://rubygems.org/ as the main source. Otherwise, it might be a temporary issue with RubyGems index.
Also make sure you are using the latest RubyGems (library) version.
$ gem update --system
Find out where your ruby is configured to look for sources:
C:\>gem sources
*** CURRENT SOURCES ***
http://gems.rubyforge.org/
If it is pointed at gems.rubyforge.org (which it is when first installed for older installation binaries) then you’re pointed at the old web server so when ruby tries to get updates it gets an HTTP redirect (302) as a response instead of the expected data in GZIP format. It apparently doesn’t have an error handler configured to detect the redirect so it just gives up.
To fix it you have to update the list of sources. First add the correct source:
C:\>gem sources -a http://rubygems.org/
http://rubygems.org/ added to sources
Then remove the deprecated one:
C:\>gem sources -r http://gems.rubyforge.org/
http://gems.rubyforge.org/ removed from sources
C:\>gem sources
*** CURRENT SOURCES ***
http://rubygems.org/
Next update your ruby system:
C:\>gem update --system
Updating RubyGems
Updating rubygems-update
Successfully installed rubygems-update-1.3.7
:0:Warning: Gem::SourceIndex#search support for String patterns is deprecated
Updating RubyGems to 1.3.7
Installing RubyGems 1.3.7
RubyGems 1.3.7 installed
=== 1.3.7 / 2010-05-13
NOTE:
http://rubygems.org is now the default source for downloading gems.
You may have sources set via ~/.gemrc, so you should replace
http://gems.rubyforge.org with http://rubygems.org
http://gems.rubyforge.org will continue to work for the forseeable future.
...
Note that update verifies that the old source URL is no longer valid…
You should now be able to continue your installation, which in my case was rake.
I ran into this problem when using a network that requires phase 2 authentication. I had forgotten to authenticate in the browser so any web request was redirected to a local authentication page. It would appear that gem does not check whether the response it receives is actually from the actual rubygems.org server (and it's can't based on the address lookup alone unless you used an ssl certificate). Rather than telling you it couldn't reach the real rubygems server, it simply tells you the payload it receives is not in the proper format (zipped). Presumable if you ran a malicious DNS server that redirected rubygems.org to your own service, you could inject anything you wanted into the gems....

Can't install any gems

I have been doing JavaScript and some Erlang for around six months and I haven't done any Rails programming lately. Today on my new PC I went to install Rails but got this error:
gem install rails
WARNING: RubyGems 1.2+ index not found for:
http://gems.rubyforge.org/
RubyGems will revert to legacy indexes degrading performance.
Bulk updating Gem source index for: htp://gems.rubyforge.org/
ERROR: While executing gem ... (Gem::RemoteSourceException)
Error fetching remote gem cache: SocketError: getaddrinfo: The system cannot
find the file specified. (http://gems.rubyforge.org/yaml)
A friend of mine said: "gem -v?" to which I responded "1.3.5". He suggested I update to 1.3.6 but I had the same problem. Then I installed a few gems for testing purposes from github.
I don't know if I'm missing a source or something, or if something changed drastically in gems.
Also:
gem sources -a htp://gemcutter.org/
Error fetching htp://gemcutter.org/:
SocketError: getaddrinfo: The system cannot find the file specified. (http://gemcutter.org/specs.4.8.gz)
For Mac OSX the solution that worked for me was:
sudo gem install rubygems-update --source http://production.s3.rubygems.org/
sudo gem update --system --source http://production.s3.rubygems.org/
It comes from some file on github of all places.
Try reinstalling rubygems from scratch here: http://rubygems.org/pages/download
RubyForge has been deprecated and may no longer be working properly. The other possibility is that when you tried to do this rubyforge or gemcutter was down, or otherwise not accessible over your network. You can also try seeing if you can reach the file on rubygems by entering it in your browser (to test your network): http://gemcutter.org/specs.4.8.gz
This question has previously been asked here: RubyGems 1.2+ index not found for:. It appears the problem was that rubyforge was blocked by China's firewall.
Good luck!

Resources