#200
Feb 08, 2010

Rails 3 Beta and RVM

Get started with Rails 3.0 Beta and install Ruby 1.9.1 using RVM: Ruby Version Manager. Stay tuned to the end for a challenge on giving back to open source.
Tags: rails-3.0
Download (32.1 MB, 8:43)
alternative download for iPod & Apple TV (16 MB, 8:43)

Resources

ruby -v
mkdir -p ~/.rvm/src/ && cd ~/.rvm/src && rm -rf ./rvm/ && git clone git://github.com/wayneeseguin/rvm.git && cd rvm && ./install
rvm install 1.9.1
rvm list
rvm 1.9.1
rvm 1.9.1 --default
rvm system
gem install tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n
gem install rails --pre
rails topscore
cd topscore
rails server
gem install sqlite3-ruby
rails generate scaffold game name:string
rake db:migrate

RSS Feed for Episode Comments 74 comments

1. Julien Biezemans Feb 08, 2010 at 00:07

We've been waiting for this one. Thank you Ryan! P.S.: What a nice episode number ;)


2. Ryan Feb 08, 2010 at 00:09

Episode 200 and Rails 3 falling at the same time.. coincidence? I think not!


3. KAN Feb 08, 2010 at 00:09

Nice thank you again :O)


4. Joost Feb 08, 2010 at 00:14

congrats with your 200th!
Keep up the good work, cheers!


5. David Feb 08, 2010 at 00:22

Congrats Ryan on episode 200!

Keep up the good work.


6. elioncho Feb 08, 2010 at 00:27

Congratulations and thank you! That's all I've to say after 200 enlightening episodes.


7. Benoist Feb 08, 2010 at 00:28

Cheers on episode 200.
I think it would have been a scary coincidence if it were episode 300 ;-)
Keep them coming tho!!


8. Jelle Feb 08, 2010 at 00:30

Did I mention I love this railscast?


9. Fredrik Feb 08, 2010 at 00:41

As a note:

rails generate scaffold game name:string

can also be shortened by calling

rails g scaffold game name:string

Gratz on the 200th episode.


10. Martijn Feb 08, 2010 at 01:29

Congratulations with #200 and thank you so much for all these wonderful explanations! Keep going, I love it!


11. Michael Feb 08, 2010 at 01:33

Gongratz with your number 200 mate! Awesome!


12. tommy Feb 08, 2010 at 01:47

Congras #200! The best site about ROR!


13. Sergio Feb 08, 2010 at 02:59

Happy #200 screencast! Thank you so much Ryan! Your tutorials are the best! [And thank you to Asciicasts too!]


14. Stewart Johnson Feb 08, 2010 at 03:29

Congratulations Ryan! Thanks for providing such a great resource for us all.


15. Wayne E. Seguin Feb 08, 2010 at 03:55

You can also segregate and use gems(ets) to install / manage your rails3 project, for example:

http://gist.github.com/296055

  ~Wayne


16. Raul Murciano Feb 08, 2010 at 03:59

Congratulations for your AWESOME work along this 200 episodes. Thank you very much Ryan!!!


17. Brain Feb 08, 2010 at 04:19

Just amazing as usual


18. Benjamin Lewis Feb 08, 2010 at 04:55

Thanks Ryan, you are awesome!


19. Dom Feb 08, 2010 at 04:55

Congratulations on episode 200 :D I've learned allot through your episodes! :) Amazing work


20. Tim Feb 08, 2010 at 05:09

Thanks Ryan and well done on reaching 200! You're making a huge contribution.


21. Jose Espinal Feb 08, 2010 at 05:17

I've been using RVM and I think it's a great idea to manage "Rubies" this way.

Thanks for the 'cast


22. Nate Bird Feb 08, 2010 at 05:28

Congrats Ryan on 200 episodes! Most shows never hit 100… 200 is legendary!

It is Fantastic that a Rails 3 intro is episode 200! Any thoughts about the adoption of Ruby 1.9 or updating plugins/gems for Rails 3? It seems a little stagnant… why is that?


23. Attila Györffy Feb 08, 2010 at 05:58

I've set up RVM just last week because of the same reason you mentioned in your Railscast.

Congratulations for your 200th episode and thank you for all your hard work. I'll keep donating back to the open source community and am looking forward to see more Rails 3 magic in the upcoming episodes.

Thanks,
Attila


24. defsdoor Feb 08, 2010 at 06:11

Just installed RVM and it's great. Conveniently solved my problems following installing ruby 1.9.1 onto my development machine that hosts applications I am not ready yet to migrate.


25. sandeep campbell Feb 08, 2010 at 06:45

Thanks Ryan,

congrats for 200


26. EppO Feb 08, 2010 at 07:06

Happy #200 episodes Ryan !

thanks for your amazing railscats, the best RoR resources ever !


27. Steve Feb 08, 2010 at 07:10

Congrats on 200! I love your work, and look forward to new videos pop up in my reader.


28. Wayne Seguin Feb 08, 2010 at 07:14

Regarding the Window's comment in the railscast. If you would like to manage multiple versions of ruby on windows please use pik which is an excellent windows tool by Gordon Thiesfeld. You can find it on Github at

http://github.com/vertiginous/pik

  ~Wayne


29. Junhyun Shin Feb 08, 2010 at 07:56

What a coincidence !!! 200th episode comes out with rials 3. I always appreciate what you have given to the community.


30. Sean Devlin Feb 08, 2010 at 10:18

Congrats on episode 200, and know that your call to give back is going beyond rails as well :)

You've helped us all out.


31. George Feb 08, 2010 at 10:58

This is great. Thanks Ryan.

I am wondering how would I switch back or downgrade to rails 2.3.4?

Thanks.


32. Nicholas Feb 08, 2010 at 11:25

All the junk in the stderr output in the terminal is a known issue (it's not for debugging). You can get rid of it if you follow the direction here: http://bit.ly/bNiLrS


33. Serguei Feb 08, 2010 at 11:52

Ryan, congratulations on episode 200! Thanks a lot for your great work. I do appreciate it!


34. Hussein Morsy Feb 08, 2010 at 15:10

Jeremy Kemper said:
Rails 3 will definitely prefer Ruby 1.9.2.

If you’re running 1.9, I’d recommend building 1.9.2dev rather than using 1.9.1. It’s big upgrade, it has quite a few behavior changes, and Rails master is developed against 1.9.2 exclusively (though we do continuous integration against 1.9.1 for good measure).

The key to *requiring* 1.9.2 is full mysql-ruby, pg, and sqlite3-ruby encoding support. These database drivers have had ages to upgrade but still aren’t up to snuff. Pitch in, make it happen, and you’ll find the database-backed web app world one step behind you.


35. Charlie Feb 08, 2010 at 15:18

Seems like only yesterday - congrats :)


36. Ryan Bates Feb 08, 2010 at 15:22

@George, if you are using rvm as I show in this episode you can simply switch back to your older version of Ruby and it will use the older version of Rails.

Also specifying the rails version in your config/environment.rb (for 2.3 projects) will work so you can easily juggle multiple Rails apps with multiple versions.

@Nicholas, thanks for the link on fixing the stderr output!

@Hussein, thanks for the corrections and update! It is good to know 1.9.2 is receiving more focus.


37. Doug Hall Feb 08, 2010 at 15:32

Is it alright to use sudo before gem install/upgrade, provided I'm using the version of ruby I had prior to using rvm? Without it, it installs gems in ~/.gem.


38. jdv Feb 08, 2010 at 17:30

Thank you for this nice episode, and for the forthcoming ones. Didn't know about rvm, it's a lifechanger!


39. jdv Feb 08, 2010 at 18:05

Notes about rubygems:

1. You forgot the rake dependency:
  gem install rake

2. you may hit upon the following error:

  ERROR: Error installing bundler:
   bundler requires RubyGems version >= 1.3.5

Then you can fix this with:

  gem install rubygems-update
  update_rubygems
  gem install bundler

Everything should be fine then.


40. jdv Feb 08, 2010 at 18:10

Also, related to the load of output and bundler error one may see when running rails commands inside a rails application, it's likely to be related to bundler.

There are some instructions about how to get rid of them:
http://www.ozmox.com/2010/02/07/fixing-rails-3-beta-invalid-gemspec-format-errors/

The proposed fix and some variants of it have made their ways into several bundler forks on github, so one may expect to install a new release of bundler soon I guess :)


41. Sai Emrys Feb 08, 2010 at 20:48

To install on OSX, this is missing two bugfix things you need to do. If you don't, you'll get an error like:

<pre>readline.c:703: error: 'filename_completion_function' undeclared (first use in this function)</pre>

1. instead of rvm install 1.8.7 or 1.9.1, run:

CPPFLAGS="-DHAVE_RL_FILENAME_COMPLETION_FUNCTION -DHAVE_RL_USERNAME_COMPLETION_FUNCTION -DHAVE_RL_COMPLETION_MATCHES" rvm install 1.8.7

(or 1.9.1 or whatever)

2. after you run <pre>rvm 1.8.7</pre> and before you go to install the rails beta gem, run:
gem sources -r http://gems.rubyonrails.org

... for whatever reason, their gemserver is really old and not compatible. It's on github anyway.


42. mikhailov Feb 08, 2010 at 22:40

Ryan, you can use "git clone --depth=1" unless full git history log is needed


43. fred zingg Feb 09, 2010 at 03:02

Thank you for this new awesome cast ryan !

But maybe you could help me with my problem :

I installed rvm, ruby-19.1 and all rubygems (tzinfo builder memcache-client rack rack-test rack-mount erubis mail text-format thor bundler i18n) without any trouble.

But when I want to install rails 3 I got this issue below.

I'm using this command :

gem install rails --pre --debug -r --http-proxy http://127.0.0.1:9666

(I'm using a proxy because i'm living in China and I cannot access directly to http://gems.rubyforge.org/ from few months. So usually when I install a new gem, i use a proxy or I download directly the gem from the web)

the trace :

Exception `Gem::Package::FormatError' at /home/Acer-fredo/.rvm/rubies/ruby-1.9.1-p378/lib/ruby/site_ruby/1.9.1/rubygems/package/tar_input.rb:110 - No metadata found!
Exception `Gem::InstallError' at /home/Acer-fredo/.rvm/rubies/ruby-1.9.1-p378/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:121 - invalid gem format for /home/Acer-fredo/.rvm/gems/ruby-1.9.1-p378/cache/activesupport-3.0.0.beta.gem
ERROR: Error installing rails:
        invalid gem format for /home/Acer-fredo/.rvm/gems/ruby-1.9.1-p378/cache/activesupport-3.0.0.beta.gem

Probably it comes from my proxy problem, but i'm not sure.

Do you have an idea or do you know where I can directly download rails-3.0.0 gems ?

Thanks.


44. George Feb 09, 2010 at 09:03

Thank you Ryan.


45. Bence Feb 09, 2010 at 12:05

Congrats for the #200. Thank you Ryan for your screencasts :)


46. Gustavo Scanferla Feb 09, 2010 at 13:29

#200, yey! Ryan, I think you should give some badges, images or buttons, etc, so more people help you promote the "Give back to open source" campaign in their sites!


47. Ryan Bates Feb 10, 2010 at 09:41

@Doug, it depends on how your system Ruby is set up, but most likely you will want to use "sudo" with that, yes.

@jdv, rvm updated rubygems and rake for me when I did the install which is why I did not cover that here. I'm guessing this is a recent change.

@fred, you can clone Rails 3 directly from GitHub instead of installing as a gem. I'm not sure how to fix the proxy error, sorry.

@Gustavo, thanks for the suggestion. Feel free to grab the ribbon and badge I use on this site.


48. steve Feb 10, 2010 at 09:49

If anyone has any hang-ups with rack-mount, this is my experience:

gem install rack-mount now installs version 0.5.0 instead of 0.4.5... not sure why that should be a problem, but when i tried to install rails --pre, i got this:

ERROR: Error installing rails:
actionpack requires rack-mount (~> 0.4.0, runtime)

I don't think rvm contributed to these problems, but i got this error after installing 1.8.7-p248 with rvm (I had installed p249 but that gave some errors when trying to install any version of Rails, so I reverted to p248 after reading that had fixed someone's problems with Rails 3). Now I still get segfaults for gem installs sometimes, then they work for no apparent reason the next time I try. That seems to be a minor issue with rvm that I can live with.

I noticed that this screencast worked with rack-mount 0.4.5. So, after uninstalling rack-mount, I tried:

gem install rack-mount --version=0.4.5

This worked the second time (after a segfault the first time).
Then I tried once more:

gem install rails --pre

And after waiting a few minutes with nothing happening...

7 gems installed
rails -v
Rails 3.0.0.beta


49. steve Feb 10, 2010 at 10:06

@fred zingg
For what it's worth, I'm in China too and have no problem accessing ruby gems from the command line without a proxy. Youtube, Vimeo, and Danwei, on the other hand...


50. Ed J Parker Feb 10, 2010 at 10:25

Thanks a million for these screencasts. As always very informative and interesting.

Keep up the good work my friend.


51. Ryan Bates Feb 10, 2010 at 12:52

For those wondering about Ruby 1.9.1 vs 1.9.2. Rails 3 does support Ruby 1.9.1 but recommends 1.9.2. Since the latter is not yet released and I had some difficulties with it, I am showing 1.9.1 here.

@steve, right, I ran into the rack-mount dependency issue this morning as well. It will be fixed soon by a new release of Rails 3 beta gem.


52. zoga Feb 11, 2010 at 07:38

happy 200! :)


53. fred zingg Feb 11, 2010 at 19:06

@steve, thank you for this info, I was pretty sure the china's great firewall do not block gems.rubyforge.org, but the fact is I only cannot access this one. In my browser I cannot open http://gems.rubyforge.org/yaml if I don't use a proxy. No problem with others gem website.

@bryan, thank you for the github link. But I still I have a problem :

I downloaded sources then build and install every packages (actionpack, activerecord, etc...), then rails rails-3.0.0.beta1. Everything seems ok, but when I run my app with rails server, it says it cannot find rails sources in gems dir. And after checking I cannot find sources in rails-3.0.0.beta1 gem dir. So maybe I did something wrong during installation.

Another question, what's the best place at the moment to talk about rails 3 install problem ?


54. Fernando Feb 11, 2010 at 19:24

Great job Ryan!


55. Jelle Vandebeeck Feb 12, 2010 at 00:29

Thnx for the Tutorial Ryan!

I have a small problem when I try to use postgresql...

I always get the following error when trying to start my server:

gem install activerecord-postgresql-adapter

But this gem doesn't exist and I installed the pg gem...

Do you know what could be the problem?

Thanx!


56. Nicolas Marchildon Feb 12, 2010 at 18:55

What do you have in your gem sources?


57. Nicolas Marchildon Feb 12, 2010 at 19:13

I was missing:

gem sources --add http://gemcutter.org


58. Fredrik Feb 14, 2010 at 02:10

@Jelle Vandebeeck & Nicolas Marchildon

Just require the gem in your Gemfile and sources should be handled at the same time. No need to let Rubygems handle the source =)


59. Felipe Orellana Feb 15, 2010 at 06:49

Hi!

Excelent work Ryan!
Congratulations for the 200th episode


60. Josh Martin Feb 15, 2010 at 09:47

Currently, `gem install rails --pre` doesn't work as it cannot pull non-pre dependencies. There is a gem called 'rails3b' which you can gem install to get around this.


61. Praveen Feb 15, 2010 at 23:33

Thanks for all the screencasts Ryan. Its been an excellent effort, Appreciate it.


62. Falk Feb 16, 2010 at 06:27

@fred zingg: For real-time help i'd suggest using irc (freenode.net, #rubyonrails) - not knowing if irc-access to freenode is "censured". But have a look at http://rubyonrails.org/community


63. Steve Byrne Feb 17, 2010 at 07:11

Thanks for yet another great episode Ryan! Congrats on #200!!!

For anyone who is installing on Ubuntu 9.10, (and using 1.9.1, per the video) you might have to do what I did to get things going:

after you install rvm, but before doing anything else, do

rvm openssl

This might require other packages (like curl), so go get those. If you don't do this, everything in the install of rails 3.0.0beta will seem to be fine until you go to test your app, and the server will get errors about openssl being missing. (I also had to install sqlite3-ruby, but that's likely because I don't have it installed by default in my non rvm world). I think building ruby and possibly rails looks for the presence of openssl, and builds accordingly, so if you don't ensure it's installed before getting ruby 1.9.1, you will have to start over from scratch by removing the .rvm directory and following the video instructions from the beginning.


64. JeremyG Feb 18, 2010 at 15:01

Some of the issues I've seen using rvm and ruby 1.9.2 on Mac OSX 10.5.8 - the first is a permissions issue where the .gem/cache directory has system and not <USER> (whoever you log in as) as the owner - chown /R .gem <USER>:staff .gem did the trick for me.
Second issue is a big crash in using 1.9.2-preview which is the default 1.9.2 install in rvm - doing rvm install ruby-1.9.2-head is reported to fix this: see https://rails.lighthouseapp.com/projects/8994/tickets/3669-ruby-192-and-rails-30pre-aborts-on-scriptgenerate


65. JeremyG Feb 18, 2010 at 15:02

Sorry - type above: chown /R <USER>:staff .gem


66. Mike Feb 18, 2010 at 23:44

Belated congratulations!

I only wish all screencasts were as well made. :-)

THANK YOU!!!


67. Fredrik Bränström Feb 21, 2010 at 16:08

Anybody getting "warning: already initialized …" messages while running some commands will want to take a look at http://github.com/carlhuda/bundler/issues/issue/51/ - but basically the fix is just to do "rvm implode" and reinstall RVM from GitHub.


68. JerraJohn Feb 25, 2010 at 19:33

Hi Ryan,

Congrats on 200 episodes.

I am trying to follow the Railscast on WinXP, with a fresh install of 1.9.1 and rails 3 beta.

When I try to start the server with "rails server" in the root directory of the topscore app I get:

C:/Ruby19/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/bin/rails:2: command not found: C:/topscore/script/rails
C:/Ruby19/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/bin/rails:2:in `exec': No such file or directory - C:/topscore/script/rails (Errno::ENOENT) from C:/Ruby19/lib/ruby/gems/1.9.1/gems/railties-3.0.0.beta/bin/rails:2:
in `<top (required)>'
        from C:/Ruby19/bin/rails:19:in `load'
        from C:/Ruby19/bin/rails:19:in `<main>'

I think this is saying that the 'rails' script in the topscore/scripts directory cannot be found, the file does exist. Although it has no file extention.

Any one got any idea why it's not working?


69. coachbags Mar 03, 2010 at 00:30

Coach catches people's eyes.people expect to see new items of Gcoach bags, while the classic items are still hot, like coach purses .
   http://bagworlds.com/


70. Matt Mar 03, 2010 at 21:50

I can't get gems to update on ruby 1.3.7 or 1.9.1 - I always get this error:

ERROR: While executing gem ... (Errno::EEXIST)
    File exists - C:

Can't find anything online to fix it.


71. Matt Mar 03, 2010 at 21:51

oh and I'm on windows 7 x64


72. Matt Mar 04, 2010 at 01:28

In case someone else has the same problem - I can get away with installing gems in radrails


73. kamagra Mar 09, 2010 at 01:27

thanks for the share


74. m65 field jacket Mar 09, 2010 at 01:27

nice post

Add your comment:

(SKIP THIS ONE)

(required)

(not shown)


(use pastie or gist for code)

sponsored by:
if you want to help:
required:
Get Quicktime Player
Give Back to Open Source