Ruby Tips: Difference between revisions

From EggeWiki
No edit summary
Line 8: Line 8:
== irb ==
== irb ==


Setup tab completion and history here:
http://wiki.rubygarden.org/Ruby/page/show/Irb/TipsAndTricks
http://wiki.rubygarden.org/Ruby/page/show/Irb/TipsAndTricks



Revision as of 18:29, 11 June 2006

Ruby Sybase Solaris

Error Messages

irb

Setup tab completion and history here: http://wiki.rubygarden.org/Ruby/page/show/Irb/TipsAndTricks

Install on Solaris

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

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

$ gem install rails --include-dependencies

Escape invalid XML characters.

This is useful for running stuff through before posting it to the wiki.

echo "<a href=\"foo\">" | ruby -pe 'gsub!(/\&/, "&"); gsub!(/"/, """); gsub!(/</, "<"); gsub!(/>/, ">"); '
&lt;a href=&quot;foo&quot;&gt;