Compiled ruby fails to find curses

cursesrubyrubygems

I'm attempting to install the sup MUA but I'm having trouble. When I try to run it, it can't find curses:

/usr/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- curses (LoadError)
...

I am installing on a server running CentOS 5. I have compiled ruby and rubygems from source, and then installed sup using rubygems. I followed this article to compile ruby.

I have found having a similar problem on ubuntu. The fix suggested there is to install libcurses-ruby, but I can't find a similarly named package in CentOS. I have installed the ncurses-devel package, as that was required for installing sup using gem. I have also installed the ncurses, cursesx and rbcurse gems, but none of these have fixed the problem.

The article above about compiling ruby said you had to recompile the zlib extension, after doing:

cd ext/zlib
sudo ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib
cd ../..
sudo make
sudo make install

So I've tried a few variants in ext/curses. The top few lines of ext/curses/extconf.rb are

require 'mkmf'

dir_config('curses')
dir_config('ncurses')
dir_config('termcap')

So I've tried a few variants of setting paths:

sudo ruby extconf.rb  --with-curses-include=/usr/include --with-curses-lib=/usr/lib  --with-ncurses-include=/usr/include --with-ncurses-lib=/usr/lib   --with-termcap-lib=/lib
sudo ruby extconf.rb  --with-curses-include=/usr/include --with-curses-lib=/usr/lib    --with-termcap-lib=/lib

and re-doing the make, but to no avail as yet. Any ideas to move it forward are welcome.

Best Answer

Got there in the end. The main problem was that subsequent make install commands failed to copy the new .so files to the right place. I also discovered I had the same issue with readline and needed to install the readline-devel package (via yum). So I did

sudo yum install readline-devel
cd ext/curses
sudo ruby extconf.rb
cd ../readline
sudo ruby extconf.rb
cd ../..
sudo make
sudo make install
sudo cp ext/curses/curses.so ext/readline/readline.so /usr/local/lib/ruby/1.8/x86_64-linux/

Obviously you may want to use an i386 directory if you are not on a 64 bit platform.

If you install ncurses-devel and readline-devel (as well as the other packages mentioned in the article) before you download and compile ruby you shouldn't need to do any of this.

Related Topic