How to run FastRI on Ruby 1.9.1

Alrighty, FastRI is a sweet program written by Mauricio Fernandez (of eigenclass.org, which is down currently for some reason) for doing RI (Ruby Documentation) lookups very quickly, it supports doing all sorts of neat things like running a DRb server for lookups and other cool things :)

Anyway, if you found this, you probably don’t want to listen to me blabber, you want to know how to get it running on Ruby 1.9.x, so I humbly present a patch!

Download the patch here (older version) version 2

Download the patch here, version 3.

First, download the FastRI tarball (version 0.3.1 is latest at the time of this writing) from rubyforge.

Here’s how to install the patch:

% tar zxf fastri-0.3.1.tar.gz
% cd fastri-0.3.1
% patch -p1 < ../fastri-0.3.1-ruby1.9.1.v2.patch
patching file bin/fastri-server
patching file lib/fastri/ri_index.rb
patching file lib/fastri/ri_service.rb
patching file lib/fastri/util.rb
patching file test/test_functional_ri_service.rb
% sudo ruby setup.rb

And you’re done! Now you’ll need to make sure to do a ‘fastri-server -b‘ to build the cache, and from there you can use FastRI the same as it was in Ruby 1.8, see:

[hinmanm@Xanadu:~]% qri String.each_codepoint
-------------------------------------------------- String#each_codepoint
str.each_codepoint {|integer| block }    => str
From
------------------------------------------------------------------------
Passes the Integer ordinal of each character in str, also known as
a codepoint when applied to Unicode strings to the given block.
"hello\u0639".each_codepoint {|c| print c, ' ' }
produces:
104 101 108 108 111 1593

Notes/Caveats/Disclaimers & Warnings:

This patch is a WORK IN PROGRESS, it may hang, crash, steal your wallet and/or delete files. I hacked it up in a day looking at FastRI because I really like using ‘qri’ for everything and was consistently annoyed by getting docs intended for 1.8. I assume no responsibility for these things.

Also, note that all tests don’t pass with this patch, I’m still working on it.

Feel free to leave any feedback for me :)

UPDATE:
New version of the patch that fixes doing a lookup on a base class instead of a method. so… version 3 right now. (link above)

UPDATE2:
I created a github project for fastri to build a gem, so you can install the gem (without patching!) using this command:

sudo gem install dakrone-fastri -s http://gems.github.com
Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists

Comments

13 Responses to “How to run FastRI on Ruby 1.9.1”

  1. roger rubygems on July 17th, 2009 5:06 am

    could you perhaps create a github project for it? Then we could all install your gem more easily like “gem install xxx-fastri” and enjoy the bliss.
    Or I could if you so desire.
    -r

  2. roger rubygems on July 17th, 2009 5:06 am

    oops forgot to check the “notify me of followup comments” box–this comment so that it will do so :)

  3. Lee on July 17th, 2009 8:17 am

    Sure, I will create a github project for it later tonight and update the post with it. Good suggestion.

  4. Lee on July 17th, 2009 12:00 pm

    @Roger,
    Alrighty, I’ve set up a project and had github build a gem, you can install it with ‘sudo gem install dakrone-fastri’. Enjoy!

  5. roger on July 20th, 2009 7:02 am

    suh weet. Maybe advertise it on ruby talk so people know? :)
    =r

  6. Lee on July 20th, 2009 10:01 pm

    Next time someone mentions FastRI I will :)

  7. Bhrgunatha on November 2nd, 2009 9:26 pm

    I came across another problem – trying to build a full text index using fastri-server -B fails.

    You can fix it by changing line 57 of fastri-server (in the make_full_text_index method) from:

    paths = [ RI::Paths::SYSDIR, RI::Paths::SITEDIR, RI::Paths::HOMEDIR ].find_all do |p|

    to

    paths = [ ::RDoc::RI::Paths::SYSDIR, ::RDoc::RI::Paths::SITEDIR, ::RDoc::RI::Paths::HOMEDIR ].find_all do |p|

  8. Moritz Bunkus on March 11th, 2010 3:15 am

    Unfortunately your patch doesn’t work right for me. It applies cleanly to fastri 0.3.1, no error messages, but whenever I invoke “fri” the output from fastri-server goes to fastri-server’s stdout, and “fri” itself only outputs a single blank line.

    Any idea how to fix that?

  9. roger on March 11th, 2010 1:05 pm

    AS a note newer versions of RDoc have an ri lookup that is *much* faster.
    Doing a gem install rdoc helps much in this regard.

    For those looking for irb fastri you could checkout ri_for
    http://github.com/rdp/ri_for

    or such (or use fastri from here). That’s about your only options :)

    -r

  10. Moritz Bunkus on March 11th, 2010 2:37 pm

    My point is that “the fastri from here” doesn’t work properly for me. fastri-server outputs to its stdout which is totally useless as fastri-server is usually started as a daemon.

    As for fastri in rb: yes, I did use it and I love it’s tab completion (well, that’s actually provided by “irb_lookup”). I didn’t know ri_for and will give it a try. irb_lookup has code for invoking ri instead of fri, so I’ll try that as well combined with the newer ri gem.

  11. Leonardo Valeri Manera on August 5th, 2010 6:35 pm

    Here its failing with a superclass mismatch for class Paragraph from rdoc/markup/fragments.rb:4 on 1.9.1p429 Winstaller as soon as any part of fastri is called …

  12. Arnaud Meuret on August 10th, 2010 4:46 am

    Yes, same thing on Linux, it has been broken since at least ruby 1.9.1p376 (2009-12-07 revision 26041).

    Sad.

  13. Arnaud Meuret on August 10th, 2010 5:49 am

    Solved the superclass mismatch problem; now it works nicely.

    All I had to do (after understanding the message, thanks to http://jackndempsey.blogspot.com/2008/06/superclass-mismatch.html) was get rid of old rdoc gems (sudo gem uni rdoc).

Leave a Reply




Bad Behavior has blocked 250 access attempts in the last 7 days.