# Ruby 1.9 side by side with 1.8

**URL:** <https://rubytalk.org/t/ruby-1-9-side-by-side-with-1-8/54913>\
**Category:** ruby-talk\
**Created:** [15 August 2009 08:25 UTC](https://rubytalk.org/t/ruby-1-9-side-by-side-with-1-8/54913 "2009-08-15T08:25:51Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oren](https://avatars.discourse-cdn.com/v4/letter/o/ecd19e/32.png) [@Oren](https://rubytalk.org/u/Oren)\
**Post date:** [15 August 2009 08:25 UTC](https://rubytalk.org/t/ruby-1-9-side-by-side-with-1-8/54913/1 "2009-08-15T08:25:51Z")

</div>

I followed this guide that uses ruby switcher -  
[http://blog.thinkrelevance.com/2009/7/29/ruby-switcher-working-with-multiple-ruby-versions-has-never-been-this-easy/comments/11186#comment-11186](http://blog.thinkrelevance.com/2009/7/29/ruby-switcher-working-with-multiple-ruby-versions-has-never-been-this-easy/comments/11186#comment-11186)

I switch to 1.9 with this command: use\_ruby\_191

I want to install rails (so I can run rake gems:install). when i type  
sudo gem install rails  
it's installing it but I can't see it in gems list. the only gem I  
see is rake.  
is there a way to access all my existing gems that works with 1.8?

here is my gem env:  
RubyGems Environment:  
&nbsp;&nbsp;- RUBYGEMS VERSION: 1.3.1  
&nbsp;&nbsp;- RUBY VERSION: 1.9.1 (2009-05-12 patchlevel 129) [i686-linux]  
&nbsp;&nbsp;- INSTALLATION DIRECTORY: /home/oren/.gem/ruby/1.9  
&nbsp;&nbsp;- RUBY EXECUTABLE: /home/oren/.ruby\_versions/ruby-1.9.1-p129/bin/  
ruby  
&nbsp;&nbsp;- EXECUTABLE DIRECTORY: /home/oren/.gem/ruby/1.9/bin  
&nbsp;&nbsp;- RUBYGEMS PLATFORMS:  
&nbsp;&nbsp;&nbsp;&nbsp;- ruby  
&nbsp;&nbsp;&nbsp;&nbsp;- x86-linux  
&nbsp;&nbsp;- GEM PATHS:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- /home/oren/.gem/ruby/1.9  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- /home/oren/.gem/ruby/1.9.1  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- /home/oren/.ruby\_versions/ruby-1.9.1-p129/lib/ruby/gems/1.9.1  
&nbsp;&nbsp;- GEM CONFIGURATION:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- :update\_sources =\> true  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- :verbose =\> true  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- :benchmark =\> false  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- :backtrace =\> false  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- :bulk\_threshold =\> 1000  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- :sources =\> ["[http://gems.rubyforge.org/](http://gems.rubyforge.org/)", "http://  
[gems.github.com](http://gems.github.com)"]  
&nbsp;&nbsp;- REMOTE SOURCES:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- [http://gems.rubyforge.org/](http://gems.rubyforge.org/)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- [http://gems.github.com](http://gems.github.com)

---

<div class="post-metadata">

**Author:** ![Roger\_Pack3](https://avatars.discourse-cdn.com/v4/letter/r/73ab20/32.png) [@Roger\_Pack3](https://rubytalk.org/u/Roger_Pack3)\
**Post date:** [15 August 2009 15:31 UTC](https://rubytalk.org/t/ruby-1-9-side-by-side-with-1-8/54913/2 "2009-08-15T15:31:31Z")

</div>

> I switch to 1.9 with this command: use\_ruby\_191
> 
> I want to install rails (so I can run rake gems:install). when i type  
> sudo gem install rails  
> it's installing it but I can't see it in gems list. the only gem I  
> see is rake.  
> is there a way to access all my existing gems that works with 1.8?

Nope the gems are kept in separate subdirectories. You could rename  
those directories, but I'd recommend keeping them separate.  
For now, I'd recommend doing "gem install" for all your gems in both  
versions of ruby.  
GL!  
-r

---

<div class="post-metadata">

**Author:** ![Oren](https://avatars.discourse-cdn.com/v4/letter/o/ecd19e/32.png) [@Oren](https://rubytalk.org/u/Oren)\
**Post date:** [15 August 2009 15:55 UTC](https://rubytalk.org/t/ruby-1-9-side-by-side-with-1-8/54913/3 "2009-08-15T15:55:06Z")

</div>

> For now, I'd recommend doing "gem install" for all your gems in both  
> versions of ruby.  
> GL!  
> -r

It's installing it but gem list shown nothing but rake!

sudo gem install rails

Successfully installed rails-2.3.3  
1 gem installed  
Installing ri documentation for rails-2.3.3...  
Updating ri class cache with 5437 classes...  
Installing RDoc documentation for rails-2.3.3...  
~\> gem list

\*\*\* LOCAL GEMS \*\*\*

rake (0.8.7)

---

<div class="post-metadata">

**Author:** ![Oren](https://avatars.discourse-cdn.com/v4/letter/o/ecd19e/32.png) [@Oren](https://rubytalk.org/u/Oren)\
**Post date:** [15 August 2009 19:40 UTC](https://rubytalk.org/t/ruby-1-9-side-by-side-with-1-8/54913/4 "2009-08-15T19:40:07Z")

</div>

I found that it installs it to the 1.8 folder!  
I tried 'sudo gem1.9 install \<gem\>' but I get:  
sudo: gem1.9: command not found

Is it something with symlinks?  
I am not sure how to deal with those...  
any help would be great. i really want to test my project on 1.9!

---

<div class="post-metadata">

**Author:** ![Daniel\_Roux1](https://avatars.discourse-cdn.com/v4/letter/d/9de053/32.png) [@Daniel\_Roux1](https://rubytalk.org/u/Daniel_Roux1)\
**Post date:** [16 August 2009 07:40 UTC](https://rubytalk.org/t/ruby-1-9-side-by-side-with-1-8/54913/5 "2009-08-16T07:40:04Z")

</div>

Try this

Create a .gemrc file in your home directory (~) to declare GEM\_PATH  
and GEM\_HOME, this is in yaml format.  
Replace the gempath with whatever the path is on your machine if its  
different.

# add what is below  
gemhome: /home/yourusername/gems  
gempath:  
- /home/yourusername/gems  
- /usr/lib/ruby/gems/1.8

Verify the environment has changed with:

$ gem environment

Hope this helps

> **···**
>
> On Aug 15, 10:54 am, oren \<orengo...@gmail.com\> wrote:
> 
> > \> For now, I'd recommend doing "gem install" for all your gems in both  
> > \> versions of ruby.  
> > \> GL!  
> > \> -r
> > 
> > It's installing it but gem list shown nothing but rake!
> > 
> > sudo gem install rails
> > 
> > Successfully installed rails-2.3.3  
> > 1 gem installed  
> > Installing ri documentation for rails-2.3.3...  
> > Updating ri class cache with 5437 classes...  
> > Installing RDoc documentation for rails-2.3.3...  
> > ~\> gem list
> > 
> > \*\*\* LOCAL GEMS \*\*\*
> > 
> > rake (0.8.7)
> 
> --  
> Daniel Roux

---

<div class="post-metadata">

**Author:** ![Oren](https://avatars.discourse-cdn.com/v4/letter/o/ecd19e/32.png) [@Oren](https://rubytalk.org/u/Oren)\
**Post date:** [15 August 2009 21:20 UTC](https://rubytalk.org/t/ruby-1-9-side-by-side-with-1-8/54913/6 "2009-08-15T21:20:05Z")

</div>

I found a solution:  
sudo ~/.ruby\_versions/ruby-1.9.1-p129/bin/gem uninstall \<gem\>

but I am looking for a way to simply use: 'sudo gem', so i can use my  
'rake gems:insall'  
I found this gem - [http://github.com/lsegal/gem-sane-binary/tree/master](http://github.com/lsegal/gem-sane-binary/tree/master)  
but not sure it's the right direction.

I started following the steps:  
sudo mv /usr/bin/ruby /usr/bin/ruby18  
sudo mv /usr/bin/irb /usr/bin/irb18  
sudo mv /usr/bin/gem /usr/bin/gem18

but i am not sure what to do in the next step:  
"Then create your ruby/irb/gem symlinks to point to whichever Ruby  
install you're using:  
ln -fs /usr/local/bin/ruby19 /usr/local/bin/ruby"

btw, here is the output of gem env:  
RubyGems Environment:  
&nbsp;&nbsp;- RUBYGEMS VERSION: 1.3.1  
&nbsp;&nbsp;- RUBY VERSION: 1.9.1 (2009-05-12 patchlevel 129) [i686-linux]  
&nbsp;&nbsp;- INSTALLATION DIRECTORY: /home/oren/.gem/ruby/1.9  
&nbsp;&nbsp;- RUBY EXECUTABLE: /home/oren/.ruby\_versions/ruby-1.9.1-p129/bin/  
ruby  
&nbsp;&nbsp;- EXECUTABLE DIRECTORY: /home/oren/.gem/ruby/1.9/bin  
&nbsp;&nbsp;- RUBYGEMS PLATFORMS:  
&nbsp;&nbsp;&nbsp;&nbsp;- ruby  
&nbsp;&nbsp;&nbsp;&nbsp;- x86-linux  
&nbsp;&nbsp;- GEM PATHS:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- /home/oren/.gem/ruby/1.9  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- /home/oren/.gem/ruby/1.9.1  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- /home/oren/.ruby\_versions/ruby-1.9.1-p129/lib/ruby/gems/1.9.1  
&nbsp;&nbsp;- GEM CONFIGURATION:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- :update\_sources =\> true  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- :verbose =\> true  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- :benchmark =\> false  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- :backtrace =\> false  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- :bulk\_threshold =\> 1000  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- :sources =\> ["[http://gems.rubyforge.org/](http://gems.rubyforge.org/)", "http://  
[gems.github.com](http://gems.github.com)"]  
&nbsp;&nbsp;- REMOTE SOURCES:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- [http://gems.rubyforge.org/](http://gems.rubyforge.org/)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- [http://gems.github.com](http://gems.github.com)

and when i switch back to 1.8 with use\_ruby\_187:  
RubyGems Environment:  
&nbsp;&nbsp;- RUBYGEMS VERSION: 1.3.3  
&nbsp;&nbsp;- RUBY VERSION: 1.8.7 (2008-08-11 patchlevel 72) [i486-linux]  
&nbsp;&nbsp;- INSTALLATION DIRECTORY: /home/oren/.gem/ruby/1.8  
&nbsp;&nbsp;- RUBY EXECUTABLE: /usr/bin/ruby1.8  
&nbsp;&nbsp;- EXECUTABLE DIRECTORY: /home/oren/.gem/ruby/1.8/bin  
&nbsp;&nbsp;- RUBYGEMS PLATFORMS:  
&nbsp;&nbsp;&nbsp;&nbsp;- ruby  
&nbsp;&nbsp;&nbsp;&nbsp;- x86-linux  
&nbsp;&nbsp;- GEM PATHS:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- /home/oren/.gem/ruby/1.8  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- /usr/lib/ruby/gems/1.8  
&nbsp;&nbsp;- GEM CONFIGURATION:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- :update\_sources =\> true  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- :verbose =\> true  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- :benchmark =\> false  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- :backtrace =\> false  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- :bulk\_threshold =\> 1000  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- :sources =\> ["[http://gems.rubyforge.org/](http://gems.rubyforge.org/)", "http://  
[gems.github.com](http://gems.github.com)"]  
&nbsp;&nbsp;- REMOTE SOURCES:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- [http://gems.rubyforge.org/](http://gems.rubyforge.org/)  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- [http://gems.github.com](http://gems.github.com)

---

<div class="post-metadata">

**Author:** ![Oren](https://avatars.discourse-cdn.com/v4/letter/o/ecd19e/32.png) [@Oren](https://rubytalk.org/u/Oren)\
**Post date:** [16 August 2009 19:00 UTC](https://rubytalk.org/t/ruby-1-9-side-by-side-with-1-8/54913/7 "2009-08-16T19:00:10Z")

</div>

Thanks Daniel,  
I ended up using this guide:  
[http://blog.michaelgreenly.com/2009/04/multiple-versions-of-ruby-on-ubuntu-3.html](http://blog.michaelgreenly.com/2009/04/multiple-versions-of-ruby-on-ubuntu-3.html)

and i can switch ruby versions with select\_ruby script that updates a  
symbolic link that points to the active version.

---

<div class="post-metadata">

**Author:** ![Oren](https://avatars.discourse-cdn.com/v4/letter/o/ecd19e/32.png) [@Oren](https://rubytalk.org/u/Oren)\
**Post date:** [15 August 2009 23:25 UTC](https://rubytalk.org/t/ruby-1-9-side-by-side-with-1-8/54913/8 "2009-08-15T23:25:12Z")

</div>

I solved it with this lines in .bashrc:

alias ruby-switch-18='sudo ln -fs /usr/bin/ruby1.8 /usr/local/bin/ruby  
&&  
&nbsp;&nbsp;sudo ln -fs /usr/bin/irb1.8 /usr/local/bin/irb &&  
&nbsp;&nbsp;sudo ln -fs /usr/bin/gem1.8 /usr/local/bin/gem' &&  
&nbsp;&nbsp;sudo ln -fs /usr/bin/rake /usr/local/bin/rake'

alias ruby-switch-19='sudo ln -fs ~/.ruby\_versions/ruby-1.9.1-p129/bin/  
ruby /usr/local/bin/ruby &&  
&nbsp;&nbsp;sudo ln -fs ~/.ruby\_versions/ruby-1.9.1-p129/bin/irb /usr/local/bin/  
irb &&  
&nbsp;&nbsp;sudo ln -fs ~/.ruby\_versions/ruby-1.9.1-p129/bin/gem /usr/local/bin/  
gem'&&  
&nbsp;&nbsp;sudo ln -fs ~/.ruby\_versions/ruby-1.9.1-p129/bin/rake /usr/local/bin/  
rake'

now i still have issue when running rake gems:install  
rake aborted!  
Could not find RubyGem test-unit (= 2.0.2)  
/home/oren/silica/Rakefile:10:in `require'

---

<div class="post-metadata">

**Author:** ![Oren](https://avatars.discourse-cdn.com/v4/letter/o/ecd19e/32.png) [@Oren](https://rubytalk.org/u/Oren)\
**Post date:** [16 August 2009 00:01 UTC](https://rubytalk.org/t/ruby-1-9-side-by-side-with-1-8/54913/9 "2009-08-16T00:01:02Z")

</div>

I solved it with this lines in .bashrc:

alias ruby-switch-18='sudo ln -fs /usr/bin/ruby1.8 /usr/local/bin/ruby  
&&  
&nbsp;&nbsp;sudo ln -fs /usr/bin/irb1.8 /usr/local/bin/irb &&  
&nbsp;&nbsp;sudo ln -fs /usr/bin/gem1.8 /usr/local/bin/gem' &&  
&nbsp;&nbsp;sudo ln -fs /usr/bin/rake /usr/local/bin/rake'

alias ruby-switch-19='sudo ln -fs ~/.ruby\_versions/ruby-1.9.1-p129/bin/  
ruby /usr/local/bin/ruby &&  
&nbsp;&nbsp;sudo ln -fs ~/.ruby\_versions/ruby-1.9.1-p129/bin/irb /usr/local/bin/  
irb &&  
&nbsp;&nbsp;sudo ln -fs ~/.ruby\_versions/ruby-1.9.1-p129/bin/gem /usr/local/bin/  
gem'&&  
&nbsp;&nbsp;sudo ln -fs ~/.ruby\_versions/ruby-1.9.1-p129/bin/rake /usr/local/bin/  
rake'

now i still have issue when running rake gems:install  
rake aborted!  
Could not find RubyGem test-unit (= 2.0.2)  
/home/oren/silica/Rakefile:10:in `require'

---

<div class="post-metadata">

**Author:** ![Kaspar\_Schiess](https://avatars.discourse-cdn.com/v4/letter/k/d78d45/32.png) [@Kaspar\_Schiess](https://rubytalk.org/u/Kaspar_Schiess)\
**Post date:** [18 August 2009 06:31 UTC](https://rubytalk.org/t/ruby-1-9-side-by-side-with-1-8/54913/10 "2009-08-18T06:31:10Z")

</div>

> and i can switch ruby versions with select\_ruby script that updates a  
> symbolic link that points to the active version.

Updating a single symbolic link wasn't enough here - I wanted to update gem binaries as well. Here's what I use (and I am sure you can deduce further details from the script)...

kaspar

> **···**
>
> --------------
> 
> #!/usr/local/share/ruby19/bin/ruby
> 
> def base\_path  
> &nbsp;&nbsp;&nbsp;'/usr/local/share/'  
> end  
> def bin\_dir(version)  
> &nbsp;&nbsp;&nbsp;File.join(base\_path, version, 'bin')  
> end  
> def lib\_dir(version)  
> &nbsp;&nbsp;&nbsp;File.join(base\_path, version, 'lib')  
> end
> 
> def replace\_symlink(source, dest)  
> &nbsp;&nbsp;&nbsp;if !File.exists?(dest) || File.symlink?(dest)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print "[#{File.basename(dest)}] "  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`sudo ln -nsf #{source} #{dest}`  
> &nbsp;&nbsp;&nbsp;end  
> end
> 
> # Iterates over binaries in version.  
> #  
> def all\_binary\_links(version) # yield: binary\_path, symlink\_path  
> &nbsp;&nbsp;&nbsp;Dir[File.join(bin\_dir(version), '\*')].each do |binary\_path|  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;binary\_name = File.basename(binary\_path)  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;yield binary\_path, File.join('/usr/bin', binary\_name)  
> &nbsp;&nbsp;&nbsp;end  
> end
> 
> def switch\_to(ruby\_version, old\_version)  
> &nbsp;&nbsp;&nbsp;# Remove current (old) symlinks  
> &nbsp;&nbsp;&nbsp;puts "Removing old links..."  
> &nbsp;&nbsp;&nbsp;all\_binary\_links(old\_version) do |bin\_path, link\_path|  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;print '.'  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`sudo rm #{link_path} 2\>/dev/null`  
> &nbsp;&nbsp;&nbsp;end  
> &nbsp;&nbsp;&nbsp;puts
> 
> &nbsp;&nbsp;&nbsp;puts "Symlinking new version..."  
> &nbsp;&nbsp;&nbsp;all\_binary\_links(ruby\_version) do |bin\_path, link\_path|  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;replace\_symlink(bin\_path, link\_path)  
> &nbsp;&nbsp;&nbsp;end  
> &nbsp;&nbsp;&nbsp;puts
> 
> &nbsp;&nbsp;&nbsp;# Symlink /lib  
> &nbsp;&nbsp;&nbsp;replace\_symlink(  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;lib\_dir(ruby\_version),  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'/usr/lib/ruby')  
> &nbsp;&nbsp;&nbsp;puts  
> end
> 
> case ARGV.first  
> &nbsp;&nbsp;&nbsp;when /19/  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch\_to :ruby19, :ruby18  
> &nbsp;&nbsp;&nbsp;when /18/  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;switch\_to :ruby18, :ruby19  
> else  
> &nbsp;&nbsp;&nbsp;puts "Run with either '19' or '18' to switch to the given ruby version..."  
> end

---

<div class="post-metadata">

**Author:** ![Ken\_Bloom](https://avatars.discourse-cdn.com/v4/letter/k/f08c70/32.png) [@Ken\_Bloom](https://rubytalk.org/u/Ken_Bloom)\
**Post date:** [19 August 2009 22:08 UTC](https://rubytalk.org/t/ruby-1-9-side-by-side-with-1-8/54913/11 "2009-08-19T22:08:40Z")

</div>

> Thanks Daniel,  
> I ended up using this guide:  
> [http://blog.michaelgreenly.com/2009/04/multiple-versions-of-ruby-on-](http://blog.michaelgreenly.com/2009/04/multiple-versions-of-ruby-on-)

ubuntu-3.html

> and i can switch ruby versions with select\_ruby script that updates a  
> symbolic link that points to the active version.

If you value a working ubuntu system in which you can install such  
packages as vim-gnome and other useful programs that use ruby, by using  
apt-get, then you'll stay \*far\* away from these instructions, and you'll  
content yourself to useing suffixes on the names of the ruby binaries to  
specify which version you want at the moment you want it.

This is your warning that following these directions will break your  
Ubuntu box in certain respects.

--Ken

> **···**
>
> On Mon, 17 Aug 2009 04:00:10 +0900, oren wrote:
> 
> --  
> Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory.  
> Department of Computer Science. Illinois Institute of Technology.  
> [http://www.iit.edu/~kbloom1/](http://www.iit.edu/~kbloom1/)
