The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Avoiding Readline

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Daniel Berger

Posts: 1383
Nickname: djberg96
Registered: Sep, 2004

Daniel Berger is a Ruby Programmer who also dabbles in C and Perl
Avoiding Readline Posted: Oct 23, 2008 1:00 PM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by Daniel Berger.
Original Post: Avoiding Readline
Feed Title: Testing 1,2,3...
Feed URL: http://djberg96.livejournal.com/data/rss
Feed Description: A blog on Ruby and other stuff.
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Daniel Berger
Latest Posts From Testing 1,2,3...

Advertisement
One of the other issues that cropped up with building Ruby from source on Windows was the lack of support for the GNU/Readline library. It's basically impossible to compile from source using MS VC++. To top it all off, I don't even really know what the thing does other than some sort of terminal key binding thingy. I'd look at the documentation for the Ruby readline library...but there isn't any.

This sucked because I thought I had to have readline support in order to run the Rails console app, for example (which I find very handy). I considered rewriting readline using pure Ruby and the Win32::API library. More on that later.

But first, an aside. What's wrong with the following code?
begin
   require 'readline'
rescue
   # Skip readline support
end

See it? Remember, a rescue clause without an explicit error class defaults to StandardError. The problem is that this code raises a LoadError, which is not a subclass of StandardError. The result is that the failed require raises an error anyway.

I noticed that I was getting weird warnings about lack of readline support when I was doing gem installations. It seemed harmless, but it annoyed me. At first I thought it was some sort of dependency in rubygems, but it turned out to be a bug in rdoc 2.x caused by the code I showed above. Once fixed (and it's already fixed in SCM, thanks Eric) the warning went away.

Back to the Rails console app (i.e. script/console), which in turn uses irb. It was choking with an error about lack of readline support. I had assumed up to this point that you had to have readline support in order to use the Rails console. The error above, however, inspired me to inspect the irb source code to see just what the heck it really needed readline for.

And sure enough, it had the same bug that rdoc 2.x had - it wasn't checking for LoadError properly. Once I made that patch (submitted here), all worked well.

As for the pure Ruby version of readline, there's one out there called Inline. Well, sort of. It's pure Ruby but has a very different, though better, API. I've requested a "readline compatibility mode" so that it can be used as a stand-in replacement for the C extension. We'll see what comes of that.

Read: Avoiding Readline

Topic: Ruby on Rails at IOD 2008 Previous Topic   Next Topic Topic: What is bryan all about?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use