Readline not working with Ruby

J

Joel VanderWerf

Stewart said:
/usr/local/src/ruby-1.8.7-p72/ext/readline $ make
make: Nothing to be done for `all'.
/usr/local/src/ruby-1.8.7-p72/ext/readline $ make install
make: Nothing to be done for `install'.
/usr/local/src/ruby-1.8.7-p72/ext/readline $ ls
Makefile README README.ja depend extconf.rb readline.bundle
readline.c readline.o
/usr/local/src/ruby-1.8.7-p72/ext/readline $

Did not do anything Does not seem anything was made.

Just to be sure, you might want to try (in the same dir):

make distclean (should delete the makefile)
ruby extconf.rb (should regenerate the makefile, and find the readline libs)
make
make install
 
B

Brian Candler

Stewart said:
/usr/local/src/ruby-1.8.7-p72/ext/readline $ make
make: Nothing to be done for `all'.
/usr/local/src/ruby-1.8.7-p72/ext/readline $ make install
make: Nothing to be done for `install'.
/usr/local/src/ruby-1.8.7-p72/ext/readline $ ls
Makefile README README.ja depend extconf.rb readline.bundle
readline.c readline.o
/usr/local/src/ruby-1.8.7-p72/ext/readline $

Did not do anything Does not seem anything was made.

Hmm, maybe 1.8.7 works differently to 1.8.6 in this regards.

Clearly something was built, because you have the object file
(readline.o) and what is presumably the shared library object (I'm
guessing that's what readline.bundle is - it would be readline.so on a
more normal Unix flavour)
$ ruby -rreadline -e 'p 42'
/usr/local/ruby_test/lib/ruby/site_ruby/1.8/i686-darwin9.6.0/readline.bundle: dlopen(/usr/local/ruby_test/lib/ruby/site_ruby/1.8/i686-darwin9.6.0/readline.bundle, 9): Symbol not found: _rl_filename_completion_function (LoadError)
Referenced from: /usr/local/ruby_test/lib/ruby/site_ruby/1.8/i686-darwin9.6.0/readline.bundle

OK, now you're getting to the bottom of it. Clearly the module was
built, but there's a runtime error when it loads, because it has linked
to a function which doesn't exist. irb doesn't show you the error
because it rescues any exceptions arising from loading the readline
library, and continues without it.

Possibly Mac's libedit isn't sufficiently compatible with libreadline,
or vice versa, but I'm afraid you'll need a Mac expert to help you.
However googling for "compile ruby mac OSX" turns up what appears to be
some useful instructions, such as
http://hivelogic.com/articles/ruby_rails_lighttpd_mysql_tiger

HTH,

Brian.
 
S

Stewart

Hmm, maybe 1.8.7 works differently to 1.8.6 in this regards.

Clearly something was built, because you have the object file
(readline.o) and what is presumably the shared library object (I'm
guessing that's whatreadline.bundle is - it would bereadline.so on a
more normal Unix flavour)


OK, now you're getting to the bottom of it. Clearly the module was
built, but there's a runtime error when it loads, because it has linked
to a function which doesn't exist. irb doesn't show you the error
because it rescues any exceptions arising from loading thereadline
library, and continues without it.

Possibly Mac's libedit isn't sufficiently compatible with libreadline,
or vice versa, but I'm afraid you'll need a Mac expert to help you.
However googling for "compile ruby mac OSX" turns up what appears to be
some useful instructions, such ashttp://hivelogic.com/articles/ruby_rails_lighttpd_mysql_tiger

HTH,

Brian.

Oddly enough its an updated version of that article I used in the
first place. Turns out there is a patch to readline. Then you can
use --with-readline-dir=/usr/local but if the patch is not applied
then readline wont work on a mac. Here is the blog post with details
of how to apply the pacth.

http://blog.bogojoker.com/2008/06/installing-ruby-187-on-mac-os-x-1053/

makes me wonder how ruby was compiled with readline in the first palce.
 
B

Brian Candler

Stewart said:
makes me wonder how ruby was compiled with readline in the first palce.

C is a tolerant language, from its K&R heritage. Calling a function
which has not been declared will only give a warning, not an error
(although gcc has a flag to turn this into an error)

That warning only becomes a hard error at link time, if the linker tries
to find the named function and fails.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,190
Members
46,736
Latest member
zacharyharris

Latest Threads

Top