Earlier I changed a gem version in the Gemfile for my Rails project. I ran bundler update gemname, and this installed more up-to-date versions of several dependencies, which kind of surprised me.
Now, I need to downgrade to the old version of the gem. I’ve changed the version back in my Gemfile, and run bundler upgrade gemname again (and bundler install for good measure), but now the gems that were upgraded earlier (the dependencies) are still the newer versions (I’d guess the gem didn’t specify versions, so it’s just using whatever is latest?).
Is there a way to downgrade those dependencies back to where they were before upgrading the gem?
Bundler can’t know the maximum version of a dependent gem if the depending gem doesn’t specify it. Unless downgrading the gem actually changes its dependencies, your only real option is to checkout a previous version of your gemfile.lock from version control. Otherwise no, you cannot do what you’re trying to do; Bundler will respect your current gemfile.lock which will not change unless the dependencies of your gem change upon downgrading it.