简体   繁体   中英

Bundle not found after changing ruby version with RVM

I feel like this is a super beginner question with an obvious answer but I'm missing it.

I'm installing a Rails project that includes a gem requiring me to use a version of Ruby that is 2.2.2 or earlier. Since my current system is set up with a newer version of Ruby, when I run bundle install , it fails because one of the gems can't be installed with the newest version of Ruby.

So, I set my system to use ruby 2.2.2 with rvm, rvm use ruby-2.2.2 .

I then run bundle install and get zsh: command not found: bundle . Why is this? All my other commands work and I can install the problem gem individually with gem install .

What am I missing?

You probably had Bundler installed for the version of ruby you've been using until this point. However, Bundler is not installed on versions of ruby provided by RVM by default, so for after you switch to ruby-2.2.2, install Bundler for that ruby:

gem install bundler

Then try running bundle install again.

If you just switched to a new version of ruby on your RVM install 2.2.2 in this case the

  gem install bundler 

command listed as correct above is only going to solve this error for that single gemset. I would suggest running the following command to avoid it for any other gemsets also tied to the same version of ruby.

  rvm use 2.2.2@global
  gem install bundler

That will put the bundler gem into your global 2.2.2 gemset making it available but over writable by all other 2.2.2 gemsets. You can also install gems like nokogiri and such that are common but very time consuming into this global 2.2 gemset

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