Using rbenv for multiple projects Feb 15 2018
I prefer to keep all my gems separated by project so I use rbenv-gemset you might want to do that too.
If you want to use a specific ruby version on a project do the following:
rbenv install 2.4.1 # you can pick any version `rbenv install -l`
then use that specif ruby-version on the project
rbenv local 2.4.1
This will create a .ruby-version file that contains the version you are using, to verify that you can check the version running:
you shoudl see 2.4.1 (for this example, or the version you choose)
Then create a gemset for that specific version.
rbenv gemset create [ruby-version] [name]
rbenv gemset create 2.4.1 myproject
Now you can add that gemset to the current project:
echo "myproject" > .rbenv-gemset
You can check where a command is located using
rbenv which [command]
rbenv which gem
this should show you that the gem command is from the ruby version you choose and if you do a gem list you'll see the gems installed for that version.
now install bundler
gem install bundler
if you do a gem list you'll see bunlder installed there
after any install or uninstall of gems that have scripts you want to call from the terminal you should run
rbenv rehash to have all the shims updated on your path.
now check where bundler command is located:
rbenv which bundler
you should see it is installed in the gemset that we previously created.
and that's it, you now have your rbenv setup and ready to use on your project without polluting your global gemsets.