Rubygems gem_server for OSX X Leopard

Posted by Ceaser Larry on June 13, 2008

In four hours I’ll be spending another four hours on a plane. I really miss having gem_server on my laptop to lookup Ruby documentation for the projects I’m working on.

So I finally broke down and decided to spend some time getting it setup. The top Google results are all outdated so here are the instructions for the current version (1.1.1)

  • Create a file located at /usr/bin/gemserver_

  • Add the following text to the file.

    #! /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
    require 'rubygems'
    require 'rubygems/doc_manager'
    require 'rubygems/server'
    
    options = {}
    options[:gemdir] = '/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8'
    options[:port] = 8808
    options[:daemon] = false
    Gem::Server.run options
    
  • Make it executable chmod +x /usr/bin/gemserver_ and start the server gemserver_

Open a browser to http://localhost:8808 and voilá

Comments Archive

  1. loqi said about 1 month later:

    Alms for the lazy?

    Hey, thanks for the code. It would’ve taken me all day to put this together. And not quite as good.

  2. polypus said about 1 month later:

    the above doesn’t work because leopard has two gem directories, the one for the shipped gems and another for user installed gems, so you won’t see all gems installed.

    but the good news is, there’s no need to write any code. if you are using the default ruby install you can just write:

    $ gem server

  3. Ceaser said about 1 month later:

    Thanks polypus, I didn’t realize the list is incomplete. I did a comparison of both methods and found that neither method actually list all the gems installed under both directories.