Avoid specifying dependencies that are subdependencies of your other dependencies

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the dependencies category.

Last Updated: 2021-05-16

In the Gemfile for my Rails application I had these lines (amongst others):

gem "rails"
gem "rake", "13.0"

After I bumped Rails to the next version, I started seeing issues like:

Gem::LoadError: You have already activated rake 13.0.0, but your Gemfile
requires rake 13.0.1. Prepending `bundle exec` to your command may solve this.

This occurred because Rails also required Rake - albeit another version of it. Naturally these requirements clashed. (The code I had that used Rake used core API features that hadn't changed in perhaps a decade).


Don't explicitly require the dependencies of your dependencies as it will lead to annoying dependency issues that are often avoidable (since you often have redundantly added these dependencies)