h1. RubyGems Frequently Asked Questions
h2. Basic Questions
h3. Why did you create this thing?
Because we needed it! And needed it badly.
h3. Is this the same
[C:\]gem install rails
"c:\ruby\bin\ruby.exe" "c:\ruby\bin\gem" install rails
Attempting local installation of 'rails'
Local gem file not found: rails*.gem
Attempting remote installation of 'rails'
ERROR: While executing gem ... (ArgumentError)
parse error on line 2, col 92:
`@gems{???"?rwdtinker-1.60o:?Gem::Specification:?@email"?steven@superant.com:?@requirements['
p{font-style: italic}. Any idea what's going on? Can I roll back to the
rubygems version I had before?
h3. Answer
It sounds like your source cache is either corrupted or not in the format expected. Around version 0.8.5 or so we switched from a YAML based cache to a marshalled cache (with a significant increase in speed). If you run a 0.8.5 or later version of gems and then later try to go back to a pre-0.8.5 version, the earlier version is confused by the data in the cache (post 0.8.5 versions are smart enough to just toss the cache if it looks bad).
To fix, just delete the source cache file (the file named @source_cache@ in the directory reported by the '@gem env gempath@' command). If you are on a unix-like OS and the source_cache is in a protected directory, you might have
another copy of the source cache available in a user owned directory (probably @$HOME/.gem/source_cache@). Delete that copy as well.
h3. RubyGems hangs while updating the source index.
p{font-style: italic}. I have a problem with RubyGems. It doesn't matter what I try to install with, it freezez.
p{font-style: italic}. Particulary I tried to execute:
gem install rails --include-dependencies
p{font-style: italic}. but the command freezez at the following message:
"Updating Gem source index for: http://gems.rubyforge.org"
h3. Answer
[I lost my internet connection while composing the answer to this question. Unfortunately, I now no longer recall what I intended to write. The answer (or at least part of the answer) is buried deep in the RubyGems mail archive. I'll try to update this after a bit of research. Sorry for leaving this question hanging.]
h3. No such file to load -- rubygems
p{font-style: italic}. When I run the gem command, I get the following error message:
ruby: No such file to load -- rubygems (LoadError)p{font-style: italic}. What's wrong? h3. Answer It looks like executing copy of Ruby does not have the RubyGems library installed. RubyGems was probably installed at one time (because the gem command is recognized), but it may have been installed on a different installation of Ruby than the one you are currently running. h4. Things to check * Check that the installation of Ruby that is running is the same one that has RubyGems installed. On a unix system, the which command (or type command) will help figure this out. * Verify that the currently running installation of Ruby does indeed have the RubyGems library installed. You should find a "rubygems.rb" file in the site_ruby/1.8 directory of the Ruby installation. These mixup can easily happen after installing a new instance of Ruby, but the old instance preceeds the new one in the PATH list. h3. Why does require return false when loading a file from a gem? p{font-style: italic}. Require returns false when loading a file from a gem. Usually require will return true when it has loaded correctly. What's wrong? h3. Answer Nothing. Well, something. But nothing you need to worry about. A false return from the require method does _not_ indicate an error. It just means that the file has already been loaded. RubyGems has a feature that allows a file to be automatically loaded when a gem is activated (i.e. selected). When you require a file that is in an inactive gem, the RubyGems software will activate that gem for you. During that activation, any autoloaded files will be loaded for you. So, by the time your require statement actually does the work of loading the file, it has already been autoloaded via the gem activation, and therefore it returns false. As we said, it is not a problem, but it sure is confusing to folks doing requires in an irb session. Future versions of RubyGems will correct this behavior. h2. Advanced Questions h3. How do I run my own gem server? The simpliest way is to run the command: gem_server This will serve all your installed gems from your local machine. The URL for the server will be @http://YOURHOSTNAME:8808@. Use the @--help@ option on @gem_server@ for a complete list of options. h3. How do I run a gem server like rubyforge? Don't forget to check out the "easy answer":http://docs.rubygems.org/read/chapter/18#page80 for running a simple gem server. But is is also fairly easy to serve gems from static files on an existing web server. Here's what you need to do. # Create a directory in the public files area of your web server (we will call that directory _BASEDIR_ in the following instructions). # Create the subdirectory _BASEDIR_/@gems@. # Copy any gems you wish to serve into the _BASEDIR_/@gems@ subdirectory. # Run the @generate_yaml_index.rb@ command (distributed with RubyGems) to generate the @yaml@ and @yaml.Z@ files needed by the RubyGems client. The command will look something like this:
generate_yaml_index.rb -d BASEDIRThat's it. The URL for the server will be whatever URL references _BASEDIR_. Just rerun the @generate_yaml_index.rb@ command whenever you add (or remove) gems from the server.