简体   繁体   中英

Whats the command to let rvm use default (like global) gemset for every new rails application I create?

I have installed rvm after installing Mac OS Lion. The problem which I am facing is whenever I try to run a new Rails application, it gives me following error.

The problem gets resolved once choose a particular rvm. $ rvm gemset use global

I know about using .rvmrc file per project. But I don't want to keep on using this command every time I create a demo project. Why doesn't rvm uses the "global" gemset automatically every time I create new project?

I used this documentation to install rvm.

JP:demo3 jayparteek$ rails s
/Users/jayparteek/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/commands/server.rb:3:in `require': no such file to load -- action_dispatch (LoadError)
    from /Users/jayparteek/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/commands/server.rb:3:in `<top (required)>'
    from /Users/jayparteek/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/commands.rb:48:in `require'
    from /Users/jayparteek/.rvm/gems/ruby-1.9.2-p290/gems/railties-3.1.1/lib/rails/commands.rb:48:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

You can specify a "default" gemset for a given ruby interpreter, by doing:

rvm use ruby-1.9.2-p0@gemsetname --default

See: http://beginrescueend.com/gemsets/using/ and http://beginrescueend.com/gemsets/basics/

it's probably a better idea to use a specific gemset for each of your projects, together with it's specific Gemfile. Problems could happen if you require '>= xyz' in your Gemfiles, and you do a bundle update in one project, but not in the other...

cd ProjectA
rvm gemset create projecta
rvm gemset use projecta

cd ProjectB
rvm gemset create projectb
rvm gemset use projectb

This way, although you update the gems in ProjectA via bundle update to the latest and greatest, they still don't get modified for ProjectB -- eliminating the possibility for interference between projects.


you can also add a .rvmrc file to a directory, eg your project directory. RVM will then use the ruby-version and gem set listed in the .rvmrc file as the default for all sub-directories.

eg assuming that you have ruby 1.9.3 installed, and a gem set "rails_3.2" for that ruby version:

# cat .rvmrc
rvm use ruby-1.9.3-p0@rails_3.2

You can make default gemset by using following command

rvm --default gemset use <gemsetname> 

or

rvm gemset use <gemsetname> --default 

For example, if you have rails4 gemset then you can make it default by

rvm --default gemset use rails4

or

rvm gemset use rails4 --default

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM