Apple made a severe booboo when they decided not to include gem_server in Leopard. If you are a Rails developer you are no doubt familiar with the ‘gem_server’ command. In case you’re not, that simple little command will start a web server at localhost:8808 and serve up documentation on all the installed Gems on the machine. This is a vital tool if you are writing code nowhere near a network connection (for example, on a 5 hour flight to Vegas).
The logic impaired reasoning behind Apples decision was that no-one would want to run up a documentation server on a desktop or notebook computer. That’s only something you’d ever want to do from a dedicated server and thus gem_server is included with Leopard Server. Apple recommend instead that you navigate through all the directories containing gems and manually open a web browser for each documentation directory. You could do that, but it’s a pain in the ass.
Browsing around my Macbook today to kill some time I found a much better solution. You could script this if you wanted, and build your own gem_server command, but really it’s so trivial to do why bother. Simply fire up irb and type in
require ‘rubygems/server’
Gem::Server.run
The rdoc server will fire up, responding to localhost:8808 just as it should. It will however only show you documentation on the gems you install, that is to say those that live in /Library/Ruby/Gems.
Have fun.
Blogged with Flock
Tags: rubyleopard gem_server
I always thought a Gem Server was the guy that worked at the Jewelry store…!
Comment by Cheryl — November 24, 2007 @ 7:03 pm |
I put this in a script in /usr/bin/gem_server and use the following launch agent to start it:
Label
local.documentation.GemServer
OnDemand
ProgramArguments
/usr/bin/gem_server
RunAtLoad
ServiceDescription
Gem Documentation Server
Comment by Ryan Hanks — December 4, 2007 @ 10:01 pm |
it appears that the engine behind this blog stripped the xml from my config, so my previous post has a bug. For more info check out http://thisoneblog.com/2007/12/starting-rubys-gemserver-in-os-x.html
Comment by Ryan Hanks — December 4, 2007 @ 10:35 pm |
Very slick – thanks Ryan!
Comment by pwrighta — December 5, 2007 @ 4:26 pm |
[...] Running gem_server on Leopard – Making up for Apple’s oversight when you want local documentation. [...]
Pingback by A Fresh Cup » Blog Archive » Double Shot #90 — December 28, 2007 @ 8:45 am |
with the newest version of rubygems it’s actually “gem server”. no longer underscored.
Comment by casual — December 31, 2007 @ 1:38 am |
I am getting a (0 for 1) ArgumentError when I try to run the Gem::Server.run statement as above.
Any ideas?
Comment by Joe — January 2, 2008 @ 3:33 pm |
[...] come across an article with leopard specific instructions. The information provided in the article (here) kept yielding me an [...]
Pingback by » gem server on leopard (not gem_server) — January 2, 2008 @ 4:33 pm |
Looks like Leopard 10.5.2 updated rubygems: now Gem::Server.run gives error about number of arguments.
Looking into source I came to try:
Gem::Server.run(:gemdir => ‘/Library/Ruby/Gems’, :port => ‘8808′)
Now server starts, but only gem displayed is rubygems, and documentation doesn’t work.
Comment by Dok — March 1, 2008 @ 10:48 am |
Ops.. now I tried “gem server” on the command line and it works like charm…
Comment by Dok — March 1, 2008 @ 10:52 am |
I just created this little ruby script according pwrighta
wrotte
#!/usr/bin/ruby
require ‘rubygems/server’
Gem::Server.run
I saved it as gem_server
changed the permissions with:
chmod a+x pathtothefile/gem_server
after that i just linked it at /usr/bin
sudo ln -s pathtothefile/gem_server /usr/bin/
Note: pathtothefile is wherever in your filesystem you stored the gem_server file.
Bye
Comment by Goyox86 — April 9, 2008 @ 11:16 am |
Great spot casual.
Simply…
gem server
Works just like “gem_server” in previous versions. Many thanks guys.
Comment by Dyno — April 18, 2008 @ 5:23 pm |
i just did a lil’ write up on this
and how to get it to run automatically
at startup:
http://crepuscular-homunculus.blogspot.com/2008/08/gemserver-lingon-on-os-x-leopard.html
Comment by polypus — August 2, 2008 @ 1:46 pm |
pwrighta – could you please update your post since it’s incorrect & googaphilic. I spent 20 minutes starting to write script and launch config to find out in you were wrong, and that in Leopard it’s just like all the commenters said:
gem server -p 8808
thanks
Comment by billspat — January 30, 2009 @ 10:28 am |