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.
bundle exec rake db:migrate
rvm use ruby-2.3.0@myapp --ruby-version --create
gem install rails
rails new .
If you're an RVM fan like myself, I would go with creating my own gemset for every rails project I start. This will make it easier for me to just use
rails commands without specifying
bundle exec every time.
Put in mind when sharing your code that some developers might be using rbenv or maybe not using a ruby version manager at all. One way you can make sure that everyone is happy and working with the same version of ruby, is to provide two additional files in your project directory (
.ruby-gemset) and track them in your project.
.ruby-version file would contain the version of ruby you're using for example
2.4.1. Note that this is compatible with both RVM and rbenv and will switch to the correct ruby version.
.ruby-gemset file is identified only by RVM; thus, switching to the correct gemset you have setup for the project.
This will make your project compatible with developers using rbenv while still making those of us using RVM happy :)
Putting all these considerations in mind, now you should care less wither people use
bundle exec or not!