Search

Recent Posts

Tags


« | Main | »

Using RVM with Hobo 1.x and Rails 3.x

By Dale Reagan | April 2, 2012

This post contains an example of the steps needed to establish a Gemset containing a specific version of Rails using RVM (Ruby Version Manager); this is needed due to the rapid changes that quickly ‘break’ Rails development efforts (well, at least for anyone trying to learn Rails, using this process should allow you to complete any tutorial out there since you ‘lock down’ your Ruby Gems.)

For this example I wanted to use Hobo 1.4 pre-release gems; this will require Rails 3.1; my ‘gemset’ was configured for Rails 3.2.3 so I show the steps used to get to Rails 3.1 with Hobo 1.4 pre-release.

All commands begin with the user prompt: [rails3@localhost ]$

Note that ‘default@some-rails-version’ = the ‘default system version of RUBY’.  If you only have one version of RUBY installed then you can simply always use ‘default’.  To see which RVM managed versions of Ruby you have install use:

[rails3@localhost ]$ rvm list

rvm rubies
=> ruby-1.9.2-p290 [ i686 ]

If you have more than one Version of Ruby installed then you should see something like this:

rvm rubies

=* ruby-1.9.2-p290 [ i686 ]
   ruby-1.9.3-p125 [ i686 ]

# => - current
# =* - current && default
#  * - default

I suggest that you edit your user PROFILE such that it announces your default RVM Gemset when you login…


Summary of steps – establish a ‘RVM Gemset’ and populate it with desired Gems

#################
[rails3@localhost ]$ rvm gemset list
[rails3@localhost ]$ rvm gemset create rails310
[rails3@localhost ]$ rails -v
[rails3@localhost ]$ rvm use default@rails310
[rails3@localhost ]$ rails -v

[rails3@localhost ]$ gem install rails -v 3.1
[rails3@localhost ]$ rvm gemset list
[rails3@localhost ]$ rails -v
[rails3@localhost ]$ gem install hobo --pre
[rails3@localhost ]$ gem install execjs
[rails3@localhost ]$ gem install therubyracer
[rails3@localhost ]$ gem list | awk '/^[a-z]/ {printf "%3d. %s\n", NR, $0}'

Details – commands & Output (which may vary on your systems…)

[rails3@localhost htutorials]$ rvm gemset list

gemsets for ruby-1.9.2-p290 (found in /usr/local/rvm/gems/ruby-1.9.2-p290)
   drails3
   global
   hobo2min
   rails300
   rails302
=> rails323
   rails_current

[rails3@localhost htutorials]$ rvm gemset create rails310
'rails310' gemset created (/usr/local/rvm/gems/ruby-1.9.2-p290@rails310).

[rails3@localhost htutorials]$ rails -v
Rails 3.2.3

[rails3@localhost htutorials]$ rvm use default@rails310
Using /usr/local/rvm/gems/ruby-1.9.2-p290 with gemset rails310
## Below we expect an error since we have install Rails yet...
 [rails3@localhost htutorials]$ rails -v
 bash: rails: command not found
[rails3@localhost htutorials]$ gem install rails -v 3.1
 Fetching: multi_json-1.2.0.gem (100%)
 Fetching: activesupport-3.1.0.gem (100%)
 Fetching: builder-3.0.0.gem (100%)
 Fetching: i18n-0.6.0.gem (100%)
 Fetching: bcrypt-ruby-3.0.1.gem (100%)
 Building native extensions. This could take a while...
 Fetching: activemodel-3.1.0.gem (100%)
 Fetching: rack-1.3.6.gem (100%)
 Fetching: rack-cache-1.0.3.gem (100%)
 Fetching: rack-test-0.6.1.gem (100%)
 Fetching: rack-mount-0.8.3.gem (100%)
 Fetching: hike-1.2.1.gem (100%)
 Fetching: tilt-1.3.3.gem (100%)
 Fetching: sprockets-2.0.3.gem (100%)
 Fetching: erubis-2.7.0.gem (100%)
 Fetching: actionpack-3.1.0.gem (100%)
 Fetching: arel-2.2.3.gem (100%)
 Fetching: tzinfo-0.3.32.gem (100%)
 Fetching: activerecord-3.1.0.gem (100%)
 Fetching: activeresource-3.1.0.gem (100%)
 Fetching: mime-types-1.18.gem (100%)
 Fetching: polyglot-0.3.3.gem (100%)
 Fetching: treetop-1.4.10.gem (100%)
 Fetching: mail-2.3.3.gem (100%)
 Fetching: actionmailer-3.1.0.gem (100%)
 Fetching: rake-0.9.2.2.gem (100%)
 Fetching: thor-0.14.6.gem (100%)
 Fetching: rack-ssl-1.3.2.gem (100%)
 Fetching: json-1.6.6.gem (100%)
 Building native extensions. This could take a while...
 Fetching: rdoc-3.12.gem (100%)
 Depending on your version of ruby, you may need to install ruby rdoc/ri data:
= 1.9.2 : nothing to do! Yay!
 Fetching: railties-3.1.0.gem (100%)
 Fetching: rails-3.1.0.gem (100%)
 Successfully installed multi_json-1.2.0
 Successfully installed activesupport-3.1.0
 Successfully installed builder-3.0.0
 Successfully installed i18n-0.6.0
 Successfully installed bcrypt-ruby-3.0.1
 Successfully installed activemodel-3.1.0
 Successfully installed rack-1.3.6
 Successfully installed rack-cache-1.0.3
 Successfully installed rack-test-0.6.1
 Successfully installed rack-mount-0.8.3
 Successfully installed hike-1.2.1
 Successfully installed tilt-1.3.3
 Successfully installed sprockets-2.0.3
 Successfully installed erubis-2.7.0
 Successfully installed actionpack-3.1.0
 Successfully installed arel-2.2.3
 Successfully installed tzinfo-0.3.32
 Successfully installed activerecord-3.1.0
 Successfully installed activeresource-3.1.0
 Successfully installed mime-types-1.18
 Successfully installed polyglot-0.3.3
 Successfully installed treetop-1.4.10
 Successfully installed mail-2.3.3
 Successfully installed actionmailer-3.1.0
 Successfully installed rake-0.9.2.2
 Successfully installed thor-0.14.6
 Successfully installed rack-ssl-1.3.2
 Successfully installed json-1.6.6
 Successfully installed rdoc-3.12
 Successfully installed railties-3.1.0
 Successfully installed rails-3.1.0
 31 gems installed

[rails3@localhost htutorials]$ rvm gemset list
gemsets for ruby-1.9.2-p290 (found in /usr/local/rvm/gems/ruby-1.9.2-p290)
 drails3
 global
 hobo2min
 rails300
 rails302
 => rails310
 rails323
 rails_current
[rails3@localhost htutorials]$ rails -v
 Rails 3.1.0

[rails3@localhost htutorials]$ gem install hobo --pre
 Fetching: hobo_support-1.4.0.pre4.gem (100%)
 Fetching: hobo_fields-1.4.0.pre4.gem (100%)
 Fetching: activesupport-3.1.4.gem (100%)
 Fetching: activemodel-3.1.4.gem (100%)
 Fetching: rack-cache-1.2.gem (100%)
 Fetching: actionpack-3.1.4.gem (100%)
 Fetching: dryml-1.4.0.pre4.gem (100%)
 Building native extensions. This could take a while...
 Fetching: will_paginate-3.0.3.gem (100%)
 Fetching: hobo-1.4.0.pre4.gem (100%)
 Fetching: activerecord-3.1.4.gem (100%)
 Fetching: activeresource-3.1.4.gem (100%)
 Fetching: actionmailer-3.1.4.gem (100%)
 Fetching: railties-3.1.4.gem (100%)
 Successfully installed hobo_support-1.4.0.pre4
 Successfully installed hobo_fields-1.4.0.pre4
 Successfully installed activesupport-3.1.4
 Successfully installed activemodel-3.1.4
 Successfully installed rack-cache-1.2
 Successfully installed actionpack-3.1.4
 Successfully installed dryml-1.4.0.pre4
 Successfully installed will_paginate-3.0.3
 Successfully installed hobo-1.4.0.pre4
 Successfully installed activerecord-3.1.4
 Successfully installed activeresource-3.1.4
 Successfully installed actionmailer-3.1.4
 Successfully installed railties-3.1.4
 13 gems installed

####### ALmost there…
## need for ALL Rails 3.1+ apps?
## gem ‘execjs’
## gem ‘therubyracer’

[rails3@localhost htutorials]$ gem install execjs
 Successfully installed execjs-1.3.0
 1 gem installed
[rails3@localhost htutorials]$ gem install therubyracer
 Fetching: libv8-3.3.10.4-x86-linux.gem (100%)
 Fetching: therubyracer-0.10.0.gem (100%)
 Building native extensions. This could take a while...
 Successfully installed libv8-3.3.10.4-x86-linux
 Successfully installed therubyracer-0.10.0
 2 gems installed

[rails3@localhost htutorials]$ gem list| awk '/^[a-z]/ {printf "%3d. %s\n", NR, $0}'
 1. actionmailer (3.1.4, 3.1.0)
 2. actionpack (3.1.4, 3.1.0)
 3. activemodel (3.1.4, 3.1.0)
 4. activerecord (3.1.4, 3.1.0)
 5. activeresource (3.1.4, 3.1.0)
 6. activesupport (3.1.4, 3.1.0)
 7. ansi (1.4.2)
 8. arel (2.2.3)
 9. bcrypt-ruby (3.0.1)
 10. builder (3.0.0)
 11. bundler (1.0.22)
 12. coffee-rails (3.1.1)
 13. coffee-script (2.2.0)
 14. coffee-script-source (1.2.0)
 15. dryml (1.4.0.pre4)
 16. erubis (2.7.0)
 17. execjs (1.3.0)
 18. hike (1.2.1)
 19. hobo (1.4.0.pre4)
 20. hobo_fields (1.4.0.pre4)
 21. hobo_support (1.4.0.pre4)
 22. i18n (0.6.0)
 23. jquery-rails (1.0.19)
 24. json (1.6.6)
 25. libv8 (3.3.10.4 x86-linux)
 26. mail (2.3.3)
 27. mime-types (1.18)
 28. multi_json (1.2.0)
 29. polyglot (0.3.3)
 30. rack (1.3.6)
 31. rack-cache (1.2, 1.0.3)
 32. rack-mount (0.8.3)
 33. rack-ssl (1.3.2)
 34. rack-test (0.6.1)
 35. rails (3.1.0)
 36. railties (3.1.4, 3.1.0)
 37. rake (0.9.2.2)
 38. rdoc (3.12)
 39. sass (3.1.15)
 40. sass-rails (3.1.6)
 41. sprockets (2.0.3)
 42. sqlite3 (1.3.5)
 43. therubyracer (0.10.0)
 44. thor (0.14.6)
 45. tilt (1.3.3)
 46. treetop (1.4.10)
 47. turn (0.9.4)
 48. tzinfo (0.3.32)
 49. uglifier (1.2.4)
 50. will_paginate (3.0.3)

Try a new Hobo projects, i.e.

hobo new test-project-one --setup

If Hobo fails then edit the project Gemfile and add entries for:

gem 'execjs'
gem 'therubyracer'

and then re-run your Hobo command – you will be prompted to ‘replace’ the Gemfile – of course you answer No since you made a custom edit.  You can select ‘Y’ for the remaining replacement queries.  Curiously, after doing this manual Gemfile edit New hobo projects did not require this work-around…

Of course, your mileage should vary a bit… 🙂

Topics: ROR, Unix-Linux-Os, Web Problem Solving, Web Technologies | Comments Off on Using RVM with Hobo 1.x and Rails 3.x

Comments are closed.


________________________________________________
YOUR GeoIP Data | Ip: 73.21.121.1
Continent: NA | Country Code: US | Country Name: United States
Region: | State/Region Name: | City:
(US only) Area Code: 0 | Postal code/Zip:
Latitude: 38.000000 | Longitude: -97.000000
Note - if using a mobile device your physical location may NOT be accurate...
________________________________________________

Georgia-USA.Com - Web Hosting for Business
____________________________________