I am using rvm, doing the following:
rvm install ree <--- (Ruby Enterprise Edition), or this can be 1.8.7 or 1.9.2
rvm ree
rvm gemset create 'proj'
cd path/to/proj
bundle install
so Gemfile in that project says:
gem 'rails', '3.0.0'
and bundle install is super fast, reporting
Using rails (3.0.0)
but after that when I type
$ rails -v
/Library/Ruby/Site/1.8/rubygems.rb:779:in `report_activate_error': Could not find RubyGem rails (>= 0) (Gem::LoadError)
from /Library/Ruby/Site/1.8/rubygems.rb:214:in `activate'
from /Library/Ruby/Site/1.8/rubygems.rb:1082:in `gem'
from /usr/bin/rails:18
$ which rails
/usr/bin/rails
so bundle install doesn’t install the rails as a gem?
but if I type script/rails -v it shows it is 3.0.0
This is correct.
bundle installwon’t install Rails as a gem in the conventional sense. Now to explain why.When Bundler runs an install, it will install the gems a directory:
~/.bundle/<type-of-ruby>/<version>/gems. This is different to the normal way of installing them to a system path. When a gem is installed at a system path, the executable is made available because that directory is within the load path. Now this is a bad thing, because you can only have one executable per gem. Have you got SomeGem v2 installed but want to use the generator from SomeGem v1? Too bad.Bundler solves this problem by installing them into the afore-mentioned location and only requiring specific versions of the gems it needs (specified inside of
Gemfile. By running simplyrails, you’re trying to run the system executable (as in one provided by doinggem install rails) rather than the Bundler one (provided by doingbundle installfor a Rails project).To run the one that Bundler installs you must run it like this
bundle exec railswithin a directory that contains aGemfilethat specifies any version of Rails. Bundler will load a specific version of Rails and you should now be able to run them side-by-side with the only tradeoff being thebundle execprefix to commands.Personally I’ve aliased this to
beand two characters before some commands is a worthwhile tradeoff to avoiding The Seventh Circle of Gem Conflict Hell in my opinion.