Internetbureau Holder

Using rails3 safely without rvm

Wijnand Wiersma wo 30 jun 10

Currently installing rails3 will cause some breakage to older rails apps and you can’t easily generate a new rails 2.3 app.
One possible solution to this is rvm but I like to use my one and only REE installation instead.
So I decided to use some bundler magic to install rails only within the bundler bubble.

Currently I don’t have any rails3 gems installed:

yaya 22:29:~:  $ gem list | grep rails
autotest-rails (4.1.0)
rails (2.3.5, 2.3.4)
rspec-rails (2.0.0.beta.8, 1.2.9)
yaya 22:29:~:  $ which ruby
/opt/ruby/bin/ruby

So I create a directory (just to be clean) and add a Gemfile:

yaya 22:29:~:  $ mkdir to_bundle
yaya 22:30:~:  $ cd to_bundle
yaya 22:30:~/to_bundle:  $ vi Gemfile
yaya 22:30:~/to_bundle:  $ cat Gemfile 
source 'http://rubygems.org'
gem 'rails', '3.0.0.beta4'

Now I run bundle install to add rails3 to the bundler bubble:

yaya 22:30:~/to_bundle:  $ bundle install
Fetching source index from http://rubygems.org/
Using rake (0.8.7) from system gems 
Using abstract (1.0.0) from system gems 
Using activesupport (3.0.0.beta4) from system gems 
Using builder (2.1.2) from system gems 
Using i18n (0.4.1) from system gems 
Using activemodel (3.0.0.beta4) from system gems 
Installing erubis (2.6.6) from rubygems repository at http://rubygems.org/ 
Using rack (1.1.0) from system gems 
Installing rack-mount (0.6.6) from rubygems repository at http://rubygems.org/ 
Using rack-test (0.5.4) from system gems 
Using tzinfo (0.3.22) from system gems 
Using actionpack (3.0.0.beta4) from system gems 
Using mime-types (1.16) from system gems 
Using polyglot (0.3.1) from system gems 
Using treetop (1.4.8) from system gems 
Installing mail (2.2.5) from rubygems repository at http://rubygems.org/ 
Using actionmailer (3.0.0.beta4) from system gems 
Using arel (0.4.0) from system gems 
Using activerecord (3.0.0.beta4) from system gems 
Using activeresource (3.0.0.beta4) from system gems 
Using bundler (0.9.26) from system gems 
Installing thor (0.13.7) from rubygems repository at http://rubygems.org/ 
Using railties (3.0.0.beta4) from system gems 
Installing rails (3.0.0.beta4) from rubygems repository at http://rubygems.org/ 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

Cool, but the rails command in my $PATH is still the rails 2.3 version. Let’s ask bundler to run the rails3 beta to generate a new app:

yaya 22:32:~/to_bundle:  $ bundle exec rails new ../new_app
     create  
     create  README
     create  Rakefile
     create  config.ru
     create  .gitignore
     create  Gemfile
     create  app
     ...... lots more output

Now when I enter my new app directory I can use all the new rails commands, I just have to prepend it with bundle exec.
I am sure you will add some shell aliases to save some keystrokes.

yaya 22:33:~/new_app:  $ bundle exec rails c
Loading development environment (Rails 3.0.0.beta4)
irb(main):001:0> 

So, this way I can use rails 2.3 the way I did and I don’t have to manage multiple ruby installations with their own gem sets.

Gepost in hor |  0 reacties

Plaats je reactie





Welcome to Holland On Rails

This weblog is the official Ruby techblog from the guys at Holder, a Ruby development company. Holder is also the company behind the RubyAndRails Europe Conference in Amsterdam.

Recente Jobs


Bekijk alle jobs »»

Gereedschapskist

Onmisbare tools voor
iedere developer!
Ruby On Rails
Framework voor de web 2.0 developer. Eindelijk vooruitgang!
TextMate
Editor for true pro's
Typ, tab, top :-)
Nee, niet voor Win.
Made On A Mac
En nou is het over met die saaie grijze Windows bak van je!

Auteurs op deze site

Chris Obdam

'Less is more' evangelist, past dit ook dagelijks toe op zijn tandenborstel.

Chiel Wester

Snelheidswonder op Ruby wielen. Leuk om mee te pair-programmen ;-) Recommend Me

Stephan Kaag

Het eerste Rails coreteam- member uit Nederland? Rails evangelist van het eerste uur.

Paul Engel

Én Rails programmeren én interfaces designen? Je zou hem superman kunnen noemen..

Dax Huiberts

Official Zip-Programmer, skinny code is helemaal zijn ding. Haalt meer code weg dan dat er bij komt.

Freek Monteban

Het nieuwste telg uit het Holland on Rails nest! Hij doet niets anders meer!

Johan Vermeulen

De stylesheet-koning uit de kop van Noord-Holland!