Using rbenv for multiple projects
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:
| |
then use that specif ruby-version on the project
| |
This will create a .ruby-version file that contains the version you are using, to verify that you can check the version running:
| |
you should see 2.4.1 (for this example, or the version you choose)
Then create a gemset for that specific version.
| |
Now you can add that gemset to the current project:
| |
You can check where a command is located using
| |
for example:
| |
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
| |
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:
| |
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.