not in gzip format error - ruby

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....

Related

Error Installing 'rhc' Rubygems on Windows

I'm trying to install and configure 'OpenShift' on Windows. I installed the necessary tools like: Git, RubyGem 2.x, but when I try to install 'rhc' ruby gem I got this error:
C:\>ruby -v
ruby 2.1.6p336 (2015-04-13 revision 50298) [x64-mingw32]
C:\>gem install rhc
ERROR: Could not find a valid gem 'rhc' (>= 0) in any repositor
C:\>
I've been searching this issue through the Internet, but it was unsuccessfully...
When I run the following command: $gem sources, I got this.
C:\>gem sources
*** CURRENT SOURCES ***
C:\>
It seems like something is wrong here, but yes, I did what you think. I "added" the source but...
C:\>gem source -a http://rubygems.org
[https://rubygems.org][1] is recommended for security over http://rubygems.org
Do you want to add this insecure source? [yn] y
Error fetching [http://rubygems.org][1]:
no such name (http://rubygems.org/specs.4.8.gz)
C:\>
What should I do guys? I've been reading so many forums and other webpages, but none of them gave me a solution to that.
Additional information: Windows 7 (x64), Ruby 2.1.6 (actually I had installed Ruby 2.2, but I found in some forums that this issue can fixed just back to and old version of Ruby). I use a proxy to connect me to Internet.
Updating info.
C:\>gem install rhc --source http://rubygems.org
ERROR: Could not find a valid gem 'rhc' (>= 0), here is why:
Unable to download data from http://rubygems.org/ - no such name (http://rubygems.org/specs.4.8.gz)
C:\>gem sources -c
*** Removed specs cache ***
C:\>gem sources -u
source cache successfully updated
C:\>gem install rhc --source http://rubygems.org
ERROR: Could not find a valid gem 'rhc' (>= 0), here is why:
Unable to download data from http://rubygems.org/ - no such name (http://rubygems.org/specs.4.8.gz)
C:\>
So the important information that you shared in your comments (you're behind a proxy) means that you will have to set some environment variables in order to use rubygems through the proxy.
In cmd.exe use:
set http_proxy=http://user:password#proxy_ip:port
or in PowerShell:
$env:http_proxy=http://user:password#proxy_ip:port
There was a case where that format didn't work and a different format had to be used:
http_proxy = proxy_ip:port
http_proxy_user = user
http_proxy_pass = password
Domain Users:
Try without the Domain prefix first, unless you know that the default Domain isn't set or that your Domain isn't the default.
Using a Domain User Login and the domain\user format, the \ must be replaced using its percent-encoding equivalent counterpart: %5C.
http://domain%5Cuser:password#proxy_ip:port
It looks like rubygems.org was having problems around the time you posted this question.
However, it should be fixed now.

Specify source when using gem install with two sources

We do have an internal gem server (http://my.gem.server) and at this server we store the gem foo-1.2.3.gem
Our users add this server to the gem source. Our gem source looks like::
*** CURRENT SOURCES ***
https://rubygems.org/
http://my.gem.server/
So far it was working wonderfully.
Then someone at the community created the foo-0.0.1.gem
Now, when our internal clients perform a gem install, the foo-0.0.1.gem from the community is installed instead of our foo-1.2.3.gem
We have tried putting our source before the standard rubygems.org but still get the same results.
Does anyone know how can I tell gem install to get the gem from our internal source?
It would be even better if it would just hit the community source if it does not find on ours.
You have two options:
Specify the source in the command
gem install --source http://my.gem.server/ install foo
Edit the ${HOME}/.gemrc file
change
:sources:
- http://rubygems.org
- http://my.gem.server
to
:sources:
- http://my.gem.server
- http://rubygems.org
In your Gemfile, separate all gems into source blocks:
source "http://my.gem.server/" do
gem "foo"
end
source "https://rubygems.org/" do
gem "rails"
end
Having global source lines and/or using :source to disambiguate can open you to security issues, as these don't actually work the way you would expect:
http://collectiveidea.com/blog/archives/2016/10/06/bundlers-multiple-source-security-vulnerability/
Any internal gem name might get claimed on rubygems.org and suddenly get installed instead.
To add on to #ptierno's answer, if you have a Gemfile or .gemspec you can use the :source parameter.
gem 'foo', :source => 'http://my.gem.server'
Which gives priority to that server for that gem only.

How to specify alternate online mirrors for rubygems

The corporate filter has mis-categorized and blocked http://production.cf.rubygems.org
When I do sudo gem install ruby-debug it gives me an error.
There is a post on help.rubygems.org about this.
How do I see what mirror it is connecting to? What file is the mirror list stored in? Is it possible to edit it and set alternate mirror?
Edit:
Running gem sources -a http://ruby.taobao.org -V gives me:
GET http://ruby.taobao.org/specs.4.8.gz
302 Moved
GET http://192.168.1.50:15871/cgi-bin/blockpage.cgi?ws-session=1563260628
200 OK
ERROR: While executing gem ... (Zlib::GzipFile::Error)
not in gzip format
You may try
# list the sources
gem sources -l
# remove a source
gem sources -r https://rubygems.org/
# add an alternative source
gem sources -a https://gems.ruby-china.com/
The above shows my steps to replace the default gem source, because the connection to rubygems.org is unstable here
To get around the firewall you can remove http source and add https source.
Following worked for me:
gem sources -r http://rubygems.org/
gem sources -a https://rubygems.org/
This is because a content filtering firewall would not be able to decipher encrypted traffic. However, this may not work if the firewall has blocked rubygems.org domain url.

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.

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