Ruby Solaris Install

From EggeWiki
(Redirected from Ruby Sybase Install)
Jump to navigation Jump to search

This is for installing Ruby without root access into your home directory. Mostly I followed the advice on http://hivelogic.com/articles/2005/12/01/ruby_rails_lighttpd_mysql_tiger and http://santanatechnotes.blogspot.com/2005/12/ruby-and-tk-on-solaris.html.

First we need to build readline:

wget ftp://ftp.gnu.org/gnu/readline/readline-5.1.tar.gz
tar xzvf readline-5.1.tar.gz
cd readline-5.1
./configure --prefix=/u/eggebr/pkgs/`archpath`
make
make install
cd ..

Now for Ruby itself:

wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.4.tar.gz
tar xzvf ruby-1.8.4.tar.gz 
cd ruby-1.8.4
./configure --prefix=/u/eggebr/pkgs/`archpath` --with-readline-dir=/u/eggebr/pkgs/`archpath`
make
make install

Assuming we have tk already installed, we can build the tk extension.

cd ext/tk
ruby extconf.rb --with-tcl-dir=/usr/local/pkgs/tcl-8.3.5 --with-tk-dir=/usr/local/pkgs/tk-8.3.5 --with-tcllib=tcl8.3 --with-tklib=tk8.3 --enable-tcltk_stubs
make && make install
cp -fr /usr/local/pkgs/tk-8.3.5/* /u/eggebr/pkgs/sunos-5.10-i86pc

Now, I just need to test things out.

require 'tk'
root = TkRoot.new() { title "Hello, world!" }
Tk.mainloop()

To get Rails installed, I'm going to need the crypto stuff working. For whatever reason, the Ruby install can find the crypto library, but the linker doesn't link an absolute path. As a consequence, I have to specify the path to my libcrypto.so.0.9.7 in my LD_LIBRARY_PATH.

$ ldd /u/eggebr/pkgs/sunos-5.10-i86pc/lib/ruby/1.8/i386-solaris2.10/digest/md5.so
        libcrypto.so.0.9.7 =>    (file not found)
        libdl.so.1 =>    /lib/libdl.so.1
        libcrypt_i.so.1 =>       /usr/lib/libcrypt_i.so.1
        libm.so.2 =>     /lib/libm.so.2
        libc.so.1 =>     /lib/libc.so.1
        libgen.so.1 =>   /lib/libgen.so.1

$ ruby -rmd5 -e 'p MD5.md5 "Hello"'
/u/eggebr/pkgs/sunos-5.10-i86pc/lib/ruby/1.8/i386-solaris2.10/digest/md5.so: ld.so.1: ruby: fatal: libcrypto.so.0.9.7: open failed: No such file or directory - /u/eggebr/pkgs/sunos-5.10-i86pc/lib/ruby/1.8/i386-solaris2.10/digest/md5.so (LoadError)
        from /u/eggebr/pkgs/sunos-5.10-i86pc/lib/ruby/1.8/md5.rb:6
$ export LD_LIBRARY_PATH=/usr/local/pkgs/openssl-0.9.7i/lib
$ ruby -rmd5 -e 'p MD5.md5 "Hello"'
-e:1: warning: parenthesize argument(s) for future version
8b1a9953c4611296a827abf8c47804d7

Now we can install Ruby Gems:

$ wget http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz
$ tar xzvf rubygems-0.8.11.tgz
$ cd ./rubygems-0.8.11
$ ruby setup.rb

If you are installing rails as sudo, it's a bit more tricky, because sudo erases your LD_LIBRARY_PATH. I simply created a small script to launch the setup.

#!/bin/sh
LD_LIBRARY_PATH=/usr/local/pkgs/openssl-0.9.7i/lib && export LD_LIBRARY_PATH
exec $@

With Ruby Gems installed, we're ready to install Rails as per http://www.rubyonrails.org/down

$ gem install rails --include-dependencies

If you've made it this far, you could venture onto installing Ruby Sybase Solaris, which will make the above seem easy.

Update May 26, 2009

I don't have a problem with the extension when building 32 bit binaries using gcc, however, sometimes the 64 bit shared libraries build with Sun's cc 5.8 have 'relocation' problems. Example:

$ ruby -e "require 'irb/completion' "
/home/egge/lib/ruby/1.8/i386-solaris2.10/readline.so: ld.so.1: ruby: fatal: relocation error: R_AMD64_32: file /home/egge/lib/ruby/1.8/i386-solaris2.10/readline.so: symbol (unknown): value 0xfffffd7fff179adc does not fit - /home/egge/lib/ruby/1.8/i386-solaris2.10/readline.so (LoadError)
        from /home/egge/lib/ruby/1.8/irb/completion.rb:10
        from -e:1:in `require'
        from -e:1

The work around seems to be to edit ext/Setup, and uncomment 'readline'. Additionally, I uncommented stringio and zlib. I tried to uncomment just 'option nodynamic' at the top, but that caused other build problems. See static linking.