Gems installation - invalid gem format

No matter on which OS you are, - XP Family, XP Pro or Ubuntu 9.10. No
matter if you have firewall ‘hyper-sensitive’ or proxy. When trying to
do gem update --system or even when trying to install a new gem like
'gem install [gem_name] I always got the below error:

serge@serge-laptop:~$ sudo gem install heroku
ERROR: Error installing heroku:
invalid gem format for /usr/lib/ruby/gems/1.8/cache/heroku-1.4.gem

serge@serge-laptop:~$ ruby -v
ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
serge@serge-laptop:~$ gem -v
1.3.5
I always get the above error of ‘…invalid gem format…’. Any idea how
to resolve that? Something goes wrong in rubygems
commits/dependencies?Thank you.

On Sat, Dec 05, 2009 at 12:22:41AM +0900, Serguei C. wrote:

ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
serge@serge-laptop:~$ gem -v
1.3.5
I always get the above error of ‘…invalid gem format…’. Any idea how
to resolve that? Something goes wrong in rubygems
commits/dependencies?Thank you.

Does this break with any other gem? Or is it only the heroku gem?

Aaron P. wrote:

On Sat, Dec 05, 2009 at 12:22:41AM +0900, Serguei C. wrote:

ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux]
serge@serge-laptop:~$ gem -v
1.3.5
I always get the above error of ‘…invalid gem format…’. Any idea how
to resolve that? Something goes wrong in rubygems
commits/dependencies?Thank you.

Does this break with any other gem? Or is it only the heroku gem?

With any other gem, even when I tried from installing Ruby, then doing
(On Windows or Ubuntu - it was the same):

gem update --system
Updating RubyGems
Updating rubygems-update
ERROR: While executing gem … (Gem::InstallError)
invalid gem format for
C:/Ruby/lib/ruby/gems/1.8/cache/rubygems-update-1.3.5
.gem

Installing fromlocal rubygems-update-1.3.5 didn’t solve the problem.
Only the error message changed. Instead of

invalid gem format for 

C:/Ruby/lib/ruby/gems/1.8/cache/rubygems-update-1.3.5

I got

invalid gem format for C:/Ruby/lib/ruby/gems/1.8/cache/[gem_name]

On Dec 4, 6:16 pm, Serguei C. [email protected] wrote:

Installing fromlocal rubygems-update-1.3.5 didn’t solve the problem.
Only the error message changed. Instead of

invalid gem format for

C:/Ruby/lib/ruby/gems/1.8/cache/rubygems-update-1.3.5

I got

invalid gem format for C:/Ruby/lib/ruby/gems/1.8/cache/[gem_name]

Can you remove 1.8/cache folder and try again?

This time, please execute the install command using --debug -V
options, which will provide us enough information to see where the
problem is.

Thank you,

Luis L. wrote:

On Dec 4, 6:16�pm, Serguei C. [email protected] wrote:

Installing fromlocal rubygems-update-1.3.5 didn’t solve the problem.
Only the error message changed. Instead of

� � invalid gem format for
C:/Ruby/lib/ruby/gems/1.8/cache/rubygems-update-1.3.5

I got

� � invalid gem format for C:/Ruby/lib/ruby/gems/1.8/cache/[gem_name]

Can you remove 1.8/cache folder and try again?

This time, please execute the install command using --debug -V
options, which will provide us enough information to see where the
problem is.

Thank you,

I tried as you asked, here is the result:

Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\serge>ruby -v
ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]

C:\Documents and Settings\serge>gem list

*** LOCAL GEMS ***

fxri (0.3.6)
fxruby (1.6.16)
hpricot (0.6.164)
log4r (1.0.5)
ptools (1.1.6)
rake (0.8.1)
ruby-opengl (0.60.0)
test-unit (2.0.1)
win32-api (1.2.1, 1.2.0)
win32-clipboard (0.4.4)
win32-dir (0.3.2)
win32-eventlog (0.5.0)
win32-file (0.5.5)
win32-file-stat (1.3.1)
win32-process (0.5.9)
win32-sapi (0.1.4)
win32-sound (0.4.1)
windows-api (0.2.4)
windows-pr (0.9.3)

C:\Documents and Settings\serge>gem update --system --debug -V
Exception NameError' at C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:134 - uninitiali zed constant Gem::Commands::UpdateCommand Updating RubyGems GET 200 OK: http://gems.rubyforge.org/latest_specs.4.8.gz Exception Errno::EEXIST’ at C:/Ruby/lib/ruby/1.8/fileutils.rb:243 -
File exists - C:/Documents and
Settings/serge/.gem/specs/gems.rubyforge.org%80
GET 200 OK: RubyGems.org | your community gem host
Exception Errno::EEXIST' at C:/Ruby/lib/ruby/1.8/fileutils.rb:243 - File exists - C:/Documents and Settings/serge/.gem/specs/gemcutter.org%80 Updating rubygems-update GET 200 OK: http://gemcutter.org/quick/Marshal.4.8/rubygems-update-1.3.5.gemspec.rz Exception Errno::EEXIST’ at C:/Ruby/lib/ruby/1.8/fileutils.rb:243 -
File exists - C:/Documents and
Settings/serge/.gem/specs/gemcutter.org%80/quick/Marshal.4.8
Installing gem rubygems-update-1.3.5
Downloading gem rubygems-update-1.3.5.gem
GET 302 Moved Temporarily:
RubyGems.org | your community gem host
GET 200 OK:
http://s3.amazonaws.com/gemcutter_production/gems/rubygems-update-1.3.5.gem
Exception Gem::Package::FormatError' at C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.r b:112 - No metadata found! Exception Gem::InstallError’ at
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/installer.rb:116 - invalid
gem format for C:/Ruby/lib/ruby/gems/1.8/cache/rubygems-update-1.3.5.gem
ERROR: While executing gem … (Gem::InstallError)
invalid gem format for
C:/Ruby/lib/ruby/gems/1.8/cache/rubygems-update-1.3.5.gem
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/installer.rb:116:in
initialize' C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/dependency_installer.rb:236:in new’
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/dependency_installer.rb:236:in
install' C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/dependency_installer.rb:219:in each’
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/dependency_installer.rb:219:in
install' C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/commands/update_command.rb:85:in execute’
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/commands/update_command.rb:81:in
each' C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/commands/update_command.rb:81:in execute’
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/command.rb:136:in
invoke' C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:105:in process_args’
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/command_manager.rb:75:in
run' C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/gem_runner.rb:39:in run’
C:/Ruby/bin/gem:24

C:\Documents and Settings\serge>

On Dec 9, 6:12 am, Serguei C. [email protected] wrote:

win32-api (1.2.1, 1.2.0)

That means that you remove the cache gem folder? The gem list is only
going to display the installed ones.

GET 200 OK:RubyGems.org | your community gem host
GET 302 Moved Temporarily:RubyGems.org | your community gem host
GET 200 OK:http://s3.amazonaws.com/gemcutter_production/gems/rubygems-update-1.3
Exception `Gem::package::FormatError’ at
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/package/tar_input.r
b:112 - No metadata found!

Can you enter the following URL in your browser, download it to a
location and then try installing it?

http://gemcutter.org/gems/rubygems-update-1.3.5.gem

The downloaded file should weight 279K.

then, from the command line where you downloaded that file:

gem install rubygems-update-1.3.5.gem

If doesn’t work, then you’re behind a firewall or proxy that is
blocking all the Amazon S3 downloads and is downloading garbage that
RubyGems cannot install

I think I found the reason. I just opened the file that Ruby pointed in
(C:/Ruby/lib/ruby/gems/1.8/cache/[gem_name]. Here is what was inside (I
had to do that much earlier without loosing so much time :(:

<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head><body><header>
</header>

<center><img src="http://192.168.50.254:7000/blocked.jpg">
<p><b>This website is blocked.</b></p>
<p><b>To unlock it's content, please send a request to <a 
href="mailto:[email protected]">[email protected]</a></b></p>
</center>
</body></html>

As you can see, the problem was that Ruby tried to go through the port
7000 that was blocked by the enterprise firewall.
Just to be sure at 100%, I took 2 laptops: with Windows XP Family and
Ubuntu 9.10 and tried to install RoR environment at home where I know
exactly my firewall configuration. And, as I expected, everything was
installed without any problem.
Thank you so much for your help. I’d like that Ruby error message to be
more user-friendly, like that one could get an idea more quickly where
to search.

When I tried to open the url you sent me:

http://gemcutter.org/gems/rubygems-update-1.3.5.gem

I got an error described before:

This website is blocked.

To unlock it's content, please send a request to [email protected]

That’s why it was clear that it was blocked by firewall. And right after
that, I decided to check the file
C:/Ruby/lib/ruby/gems/1.8/cache/[gem_name] and saw the port number.
Thank you again.

On Dec 11, 5:56 am, Serguei C. [email protected] wrote:

This website is blocked.

installed without any problem. Thank you so much for your help. I'd like that Ruby error message to be more user-friendly, like that one could get an idea more quickly where to search.

It was pointed several times over this thread and by others that you
may be behind a firewall.

A proper firewall shouldn’t return HTTP 200 OK but instead something
else.

The problem is not Ruby, but the firewall, how can RubyGems determine
what will do so many proxy/firewalls in relation to blocking of
content?

Glad to know you figure it out.

When I tried to open the url you sent me:

http://gemcutter.org/gems/rubygems-update-1.3.5.gem

I got an error described before:

This website is blocked.

To unlock it's content, please send a request to [email protected]

That’s why it was clear that it was blocked by firewall. And right after
that, I decided to check the file
C:/Ruby/lib/ruby/gems/1.8/cache/[gem_name] and saw the port number.
Thank you again.
I googled so much but didn’t find any info describing the port number
that gem command usually used to connect to the repository. I thought it
was always 80 when usin cmd prompt or terminal window. Have you ever
heard anything about that?