---
book:
- chapter:
- title: Basic Questions
page:
- body: |
Because we needed it! And needed it badly.
title: Why did you create this thing?
- body: "No. It is based on the same idea, but the code was written from scratch (initially) at RubyConf 2003. "
title: Is this the same
$ gem list RedCloth
*** LOCAL GEMS ***
RedCloth (4.1.1)
$ ruby -rubygems -e 'require "RedCloth"'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- RedCloth (LoadError)
from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
from -e:1
$ gem contents --no-prefix RedCloth | grep lib
lib/case_sensitive_require/RedCloth.rb
lib/redcloth/erb_extension.rb
lib/redcloth/formatters/base.rb
lib/redcloth/formatters/html.rb
lib/redcloth/formatters/latex.rb
lib/redcloth/formatters/latex_entities.yml
lib/redcloth/textile_doc.rb
lib/redcloth/version.rb
lib/redcloth.rb
$ ruby -rubygems -e 'require "redcloth"'
$ # success!
If you're requiring the correct file, maybe `gem` is using a different ruby than `ruby`:
$ which ruby
/usr/local/bin/ruby
$ gem env | grep 'RUBY EXECUTABLE'
- RUBY EXECUTABLE: /usr/local/bin/ruby1.9
In this instance we've got two ruby installations so that `gem` uses a different version than `ruby`. You can probably fix this by adjusting a symlink:
$ ls -l /usr/local/bin/ruby*
lrwxr-xr-x 1 root wheel 76 Jan 20 2010 /usr/local/bin/ruby@ -> /usr/local/bin/ruby1.8
-rwxr-xr-x 1 root wheel 1213160 Jul 15 16:36 /usr/local/bin/ruby1.8*
-rwxr-xr-x 1 root wheel 2698624 Jul 6 19:30 /usr/local/bin/ruby1.9*
$ ls -l /usr/local/bin/gem*
lrwxr-xr-x 1 root wheel 76 Jan 20 2010 /usr/local/bin/gem@ -> /usr/local/bin/gem1.9
-rwxr-xr-x 1 root wheel 550 Jul 15 16:36 /usr/local/bin/gem1.8*
-rwxr-xr-x 1 root wheel 550 Jul 6 19:30 /usr/local/bin/gem1.9*
You may also need to give `irb` the same treatment.
title: Why does require 'some_gem' fail?
- body: |
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.
title: Why does require return false when loading a file from a gem?
- body: |-
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. title: No such file to load -- rubygems - body: |- You can submit bug reports in the "RubyGems bug tracker":http://rubyforge.org/tracker/?func=add&group_id=126&atid=575 You will need a RubyForge account. If you take a look at the "RubyGems bug list":http://rubyforge.org/tracker/?func=browse&group_id=126&atid=575 to see if the bug has already been filed the maintainers will really appreciate it. title: I think I found a bug - body: | p{font-style: italic}. I have a problem with RubyGems. It doesn't matter what I try to install with, it freezes. p{font-style: italic}. Particulary I tried to execute: gem install rails --include-dependencies p{font-style: italic}. but the command freezes at the following message: "Updating Gem source index for: http://gems.rubyforge.org" h3. Answer You'll need to upgrade RubyGems to a modern version. You can find instructions in the Downloads link at the top of this page. title: RubyGems hangs while updating the source index. - title: Advanced Questions page: - body: |- 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. title: How do I run my own gem server? - body: | 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_index@ gem command in order to generate the @yaml@ and @yaml.Z@ files needed by the RubyGems client. The command will look something like this:
gem generate_index -d BASEDIRThat's it. The URL for the server will be whatever URL references _BASEDIR_. Just rerun the @generate_index@ gem command whenever you add (or remove) gems from the server. title: How do I run a gem server like rubyforge? body: "" title: RubyGems Frequently Asked Questions