100% found this document useful (2 votes)
353 views10 pages

Installing and Using Ruby 1.9

This document provides instructions for installing multiple Ruby versions (1.8 and 1.9) on the same machine. It discusses downloading and configuring Ruby 1.9, setting up symlinks, installing gems, fixing issues with gem installation overwriteing executables, installing specific gems like MySQL and postgres, features of Ruby 1.9 like the new hash and lambda syntax, common encoding issues, and asks what other issues the reader has encountered.

Uploaded by

lsegal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
353 views10 pages

Installing and Using Ruby 1.9

This document provides instructions for installing multiple Ruby versions (1.8 and 1.9) on the same machine. It discusses downloading and configuring Ruby 1.9, setting up symlinks, installing gems, fixing issues with gem installation overwriteing executables, installing specific gems like MySQL and postgres, features of Ruby 1.9 like the new hash and lambda syntax, common encoding issues, and asks what other issues the reader has encountered.

Uploaded by

lsegal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Ruby 1.9 + Ruby 1.

8
Installing and using multiple Ruby installs on the same machine

Most of this stuff can be found on my blog:


http://gnuu.org
Plan of Action
• Install Ruby 1.9

• Setup Symlinks and Ruby Switcher Script

• Install Gems (mysql, hpricot, BlueCloth, etc.)

• Quick Overview of New Features

• Common Issues / Let’s Talk Encodings

• What Works? What Doesn’t Work?


Installing Ruby 1.9
• Download Ruby 1.9 from http://ruby-lang.org

• http://gnuu.org/2009/06/14/installing-ruby-1-8-1-9-side-by-side/

• ~/ruby-1.9.1$ ./configure --program-suffix=19

• ln -fs /usr/local/bin/ruby19 /usr/local/bin/ruby


ln -fs /usr/local/bin/irb19 /usr/local/bin/irb
ln -fs /usr/local/bin/gem19 /usr/local/bin/gem

• See blog (above) for tiny “Quick Switcher” shell script


Fixing Gem Installs
• gem overwrites executables with hardcoded shebang.

• Either install all gems with suffix (spec1.9) or use gem-sane-binary

• gem-sane-binary: RubyGems 1.3.1+ plugin I wrote to write shebang to


`ruby` symlink (if exists).

• You can point the ruby symlink at anything.

• No need to type suffixes (or modify programs that don’t use suffixes)
Installing Gems
• Most (important) gems have by now been ported, officially or
unofficially.

• http://isitruby19.com has a list and details to find unofficial working


Github forks

• Some official working gems: hpricot, BlueCloth, sqlite3-ruby

• Unofficially working gems: mysql, postgres


Installing MySQL

• Look for “mysql-ruby” on RubyForge: http://rubyforge.org/frs/?group_id=4550

• Download and run `ruby extconf.rb -- --with-mysql-dir=/path/to/mysql`

• make && sudo make install

• You can find Github forks and gem servers with this pre-packaged.
Ruby 1.9 Features
• New hash syntax: {a: 1, b: 2} => {:a => 1, :b => 2} (and they’re ordered)

• Unicode support (we’ll talk about that)


• New lambda syntax supports splats, default args:
meth = ->(a, b = true) do [a, b] end
meth.(1) #=> [1, true]

• Symbols compare with strings: :foo =~ /o/, :foo[0] == “f”

• Plenty of other great additions to stdlib (Object#tap, Fibers)


Common Issues (Mostly Encodings)
• http://gnuu.org/2009/02/02/ruby-19-common-problems-pt-1-encoding/

• You might have seen: Invalid multibyte char (US-ASCII)

• Most issues solved with encoding shebang (“# encoding: utf-8” at top
of file)
• >> “ç”.encoding
=> #<Encoding:UTF-8>

>> “ç”.encode(“us-ascii”)
Encoding::UndefinedConversionError: "\xC3\xA7" from UTF-8 to US-ASCII

>> “ç”.force_encoding(“us-ascii”)
=> “\xC3\xA7”
What Works? What Doesn’t Work?

• TextMate:
•I’ve had issues with Git.tmbundle but fixed most of them
•Posted about it on my blog
•Works well now (minus a few minor things)
•I can switch back to 1.8 (ruby-switch-18) when I’m having problems
What Issues Have You Had?
Discuss.

You might also like