Is there a difference between using RVM local gemset and using Bundle exec?

Viewed 514

There is fundamental problem with ruby gem sets where commands like rake xxxx might create error because command might use global version of rake while your gemfile requires very specific version.

I know 2 ways to mitigate this.

  1. Use bundle exec in front of rake and rails commands. For example bundle exec rake db:migrate Adding this in front makes sure command is executed in relation of the current bundle meaning the bundle that got created when you run bundle install.

  2. Using RVM. There is less known way of creating local gemset with RVM. First you create directory for your new app in this case mkdir myapp, cd myapp and then run rvm use ruby-2.3.0@myapp --ruby-version --create for creating local gem set with nothing in it. Now you can run gem install rails and rails new . to create rails myapp with it's dedicated gem environment in the folder you are in.

As nice extra RVM will swap to right gemset every time you cd to myapp directory automatically.

As for as I understand both approaches work, but are there any known issues why you would not use one of approaches above?

2 Answers
Related