Ruby 1.9

From WTFwiki
Jump to navigation Jump to search

On christmas 2007 ruby 1.9.0.0 was released. It's intended to be a developer's release to allow people to transition their libraries/code to the 1.9 changes. The planned release schedule for 1.9 is to release updates to 1.9.0 every month, numbered like 1.9.0.x and then sometime in early 2008 (Aprilish?) to make a 1.9.1 release which should be production grade.

This page is just a repository of information I've gleaned from playing with 1.9...

Compiling

I HIGHLY recommend you configure with --prefix=/opt/ruby19 or --program-suffix=19 (or some variation on this theme). Ruby 1.9 is NOT ready for being the default ruby runtime on any machine.

FreeBSD

Tested on i386. Note: the -O2 optimization causes issues on FreeBSD

 ./configure --with-X11-dir=/usr/local --with-tcl-include=/usr/local/include/tcl8.4 --with-tk-include=/usr/local/include/tk8.4 CFLAGS="-g"

IRIX

Needs >= 1.9.0.1 or my patch. You might not need --enable-wide-getaddrinfo if you're not using IPv6. Your tk/readline paths will be different if you're not using pkgsrc like I am.

 ./configure --enable-wide-getaddrinfo --with-X11-dir=/usr/lib/X11 --with-tk-dir=/usr/pkg --with-readline-dir=/usr/pkg

OpenBSD

Tested on sparc64. Works out of the box.

NetBSD

Tested on i386, Alpha. Works out of the box.

Making ruby/tk work on 1.9

Ruby/tk looks like it hasn't been entirely updated for 1.9 yet so there's a couple niggles that need patching.

Basically I removed all references to Thread.critical in lib/ruby/1.9.0/tk.rb and I replaced the def TkRoot.new(..) and def TkRoot.destroy(...) with def self.(new|destroy) in lib/ruby/1.9.0/tk/root.rb. That has resolved the issues I've encountered thus far.

Changes that have broken my code

Format of 'caller'

 ruby -ve 'def foo; puts caller; end; proc{foo}.call'
 ruby 1.8.6 (2007-03-13 patchlevel 0) [mips-irix6.5]
 -e:1
 -e:1:in `call'
 -e:1
 ruby 1.9.0 (2007-12-25 revision 14709) [mips-irix6.5]
 -e:1:in `block in <main>'
 -e:1:in `call'
 -e:1:in `<main>'

This only broke stuff because I have an awful piece of code that parses the callstack to get a filename out. The main thing to note is that extra : and the accounting for <main> and blocks.

Object#instance_variables returns array of symbols not strings

 ruby -ve '@foo=1;@bar=2;p self.instance_variables'
 ruby 1.8.6 (2007-03-13 patchlevel 0) [mips-irix6.5]
 ["@foo", "@bar"]
 ruby 1.9.0 (2007-12-25 revision 14709) [mips-irix6.5]
 [:@foo, :@bar]

This is an excellent change, but it will break any code that assumes an array of strings should be returned.

See Also

  • Changes in 1.9 - Slightly dated, will be replaced with a newer, automatically generated one soon, apparently.