On May 19, 2005, at 7:58 PM, Shugo Maeda wrote:

> The original libedit provides a compatibility layer for the GNU  
> Readline
> API by readline.h.
> If /usr/include/readline/readline.h doesn't exist on Tiger, extconf.rb
> of ruby-1.8.2 doesn't create Makefile, so you can't see compile  
> errors.
> Is your installation of Tiger different from Jules and Ryan?

I've finally had time to dig deeper into this. I just did a make  
realclean, cvs update on ruby_1_8, and a full build and install.  
Without tweaking it appears that readline support is built and  
installed, but it doesn't work:

> 501 % type irb
> /usr/local/bin/irb
> 502 % irb
> dyld: NSLinkModule() error
> dyld: Symbol not found: _rl_filename_completion_function
>   Referenced from: /usr/local/lib/ruby/1.8/powerpc-darwin8.1.0/ 
> readline.bundle
>   Expected in: flat namespace

IF, however, I do the following:

> cd ext/readline
> ruby extconf.rb
> make
> sudo cp readline.bundle /usr/local/lib/ruby/site_ruby/1.8/powerpc- 
> darwin8.1.0

then irb works fine and seems to have full readline support. I  
confirmed that the bundle as created by the top level make is a  
different size than a make in the readline directory:

578 % find . -name readline.bundle -ls
4675296   72 -rw-rw-r--    1 ryan     staff       35332 May 27  
18:38 ./.ext/powerpc-darwin8.1.0/readline.bundle
4677168   72 -rw-rw-r--    1 ryan     staff       36076 May 27  
18:41 ./ext/readline/readline.bundle

My guess is that there is a simple config issue, or maybe a  
difference between running extconf.rb with a full ruby vs miniruby?  
Indeed, that appears to be the case upon further research. If I nuke  
ext/readline/Makefile, run configure again (not sure if that was  
necessary but I figured it wouldn't hurt) and do a top level make it  
uses:

> gcc -fno-common -g -O2 -pipe -fno-common  -I. -I../.. -I../../. - 
> I../.././ext/readline -DHAVE_READLINE_READLINE_H - 
> DHAVE_READLINE_HISTORY_H -DHAVE_RL_FILENAME_COMPLETION_FUNCTION - 
> DHAVE_RL_DEPREP_TERM_FUNCTION -DHAVE_RL_COMPLETION_APPEND_CHARACTER  
> -DHAVE_RL_BASIC_WORD_BREAK_CHARACTERS - 
> DHAVE_RL_COMPLETER_WORD_BREAK_CHARACTERS - 
> DHAVE_RL_BASIC_QUOTE_CHARACTERS - 
> DHAVE_RL_COMPLETER_QUOTE_CHARACTERS - 
> DHAVE_RL_FILENAME_QUOTE_CHARACTERS - 
> DHAVE_RL_ATTEMPTED_COMPLETION_OVER -DHAVE_RL_LIBRARY_VERSION - 
> DHAVE_RL_EVENT_HOOK  -c readline.c
> cc -dynamic -bundle -undefined suppress -flat_namespace  -L"../.." - 
> o ../../.ext/powerpc-darwin8.1.0/readline.bundle readline.o  - 
> lreadline -lncurses  -ldl -lobjc

and then get:

> 633 % ./ruby -Ilib:.ext/powerpc-darwin8.1.0 bin/irb
> dyld: NSLinkModule() error
> dyld: Symbol not found: _rl_filename_completion_function
>   Referenced from: .ext/powerpc-darwin8.1.0/readline.bundle
>   Expected in: flat namespace
>
> Trace/BPT trap

but this works:

> 634 % cd ext/readline/
> ./ext/readline/
> 635 % ruby extconf.rb
> checking for tgetnum() in -lncurses... yes
> checking for readline/readline.h... yes
> checking for readline/history.h... yes
> checking for readline() in -lreadline... yes
> checking for rl_filename_completion_function... yes
> checking for rl_deprep_term_function... yes
> checking for rl_completion_append_character... yes
> checking for rl_basic_word_break_characters... yes
> checking for rl_completer_word_break_characters... yes
> checking for rl_basic_quote_characters... yes
> checking for rl_completer_quote_characters... yes
> checking for rl_filename_quote_characters... yes
> checking for rl_attempted_completion_over... yes
> checking for rl_library_version... yes
> checking for rl_event_hook... yes
> checking for rl_cleanup_after_signal()... yes
> checking for rl_clear_signals()... yes
> checking for rl_vi_editing_mode()... yes
> checking for rl_emacs_editing_mode()... yes
> checking for rl_clear_signals()... yes
> checking for replace_history_entry()... yes
> checking for remove_history()... yes
> creating Makefile
> 638 % rm *.o *.bundle
> 639 % make
> gcc -fno-common -g -O2 -pipe -fno-common  -I. -I/usr/local/lib/ruby/ 
> 1.8/powerpc-darwin8.1.0 -I/usr/local/lib/ruby/1.8/powerpc- 
> darwin8.1.0 -I. -DHAVE_READLINE_READLINE_H - 
> DHAVE_READLINE_HISTORY_H -DHAVE_RL_FILENAME_COMPLETION_FUNCTION - 
> DHAVE_RL_DEPREP_TERM_FUNCTION -DHAVE_RL_COMPLETION_APPEND_CHARACTER  
> -DHAVE_RL_BASIC_WORD_BREAK_CHARACTERS - 
> DHAVE_RL_COMPLETER_WORD_BREAK_CHARACTERS - 
> DHAVE_RL_BASIC_QUOTE_CHARACTERS - 
> DHAVE_RL_COMPLETER_QUOTE_CHARACTERS - 
> DHAVE_RL_FILENAME_QUOTE_CHARACTERS - 
> DHAVE_RL_ATTEMPTED_COMPLETION_OVER -DHAVE_RL_LIBRARY_VERSION - 
> DHAVE_RL_EVENT_HOOK -DHAVE_RL_CLEANUP_AFTER_SIGNAL - 
> DHAVE_RL_CLEAR_SIGNALS -DHAVE_RL_VI_EDITING_MODE - 
> DHAVE_RL_EMACS_EDITING_MODE -DHAVE_RL_CLEAR_SIGNALS - 
> DHAVE_REPLACE_HISTORY_ENTRY -DHAVE_REMOVE_HISTORY  -c readline.c
> cc -dynamic -bundle -undefined suppress -flat_namespace  -L"/usr/ 
> local/lib" -o readline.bundle readline.o  -lreadline -lncurses  - 
> ldl -lobjc
> 640 % cd ../..
> 641 % ./ruby -Ilib:ext/readline bin/irb
> irb(main):001:0> 1+1
> => 2
> irb(main):002:0> 1+1
> => 2