Max Millington
Max Millington

Reputation: 4473

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?

Upvotes: 3

Views: 5462

Answers (2)

Michael Deering
Michael Deering

Reputation: 444

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

Upvotes: 4

PinnyM
PinnyM

Reputation: 35531

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.

Upvotes: 25

Related Questions