Using Rails:
If Bundler retrieves the proper gems (and dependencies) and locks them in the Gemfile.lock for a given project, isn't using a gemset for this same project overkill? I've been told that using gemsets is still a good practice because merely having 2 versions of the same gem in your current PATH can cause conflicts. Is this right, or do you only need one or the other: Bundler or RVM?
It's redundant to use RVM's gemsets if you're using bundler.
Conflicts when using Bundler arise primarily for two reason:
rails g migrationor callingrake?The first issue can be resolved if you're careful about specifying your gem versions more explicitly in your Gemfile.
When working within a project with a Gemfile, the second issue can be resolved by prefixing executable calls with
bundle exec, which will run the command within the context of the current bundle (e.g.bundle exec rake db:migrate).When you want to specify a gem version outside of a Gemfile's context (e.g.
rails new fancy_app), you can specify any gem's version by providing it as the first argument surrounded by underscores.RubyGems handles all of this for you by creating version-aware wrappers for any gem's executables. Just run
cat `which gem_executable`(withgem_executablebeing something likerake,rails,foreman,pry, etc.) and have a look.Stephen Ball has a good blog post about how to use Bundler instead of RVM gemsets, which explores the overlaps in further detail.
While RVM's gemsets are not necessary, RVM provides other conveniences:
PATH, so you can avoid typingbundle exec. Note the bundler plugin foroh-my-zshprovides the same featureThe ruby version manager
rbenvprovides similar features as well.