So you're getting an error like this:
undefined method `activate_bin_path' for Gem:Module (NoMethodError)
Here is what happened:
- You installed a recent version of Rubygems
- You installed some gems that install a binary (like
bundle
,rake
orrails
) with code that only works with modern Rubygems versions - You downgraded Rubygems to an older versions, which doesn't change any binaries
- When calling binaries with the old Rubygems version, it cannot process the line
Gem.activate_pin_path(...)
that was written out by the new Rubygems version.
In general, try to upgrade/downgrade Rubygems to the version you want before installing any gems. This way you won't run into the issue above.
Fixing an existing Ruby installation (preferred method)
Simply run
gem pristine --all
Fixing an existing Ruby installation (fallback method)
- Uninstall all gems (including bundler) or remove and re-install the Ruby version
- Upgrade/downgrade to the version you want using
gem update --system="x.y.z"
. - Install a recent version of bundler using
gem install bundler
. - Install the gems you want using
bundle install
orgem install
.
Also see: When upgrading/downgrading RubyGems and Bundler on a server, you must clear bundled gems
Posted by Henning Koch to makandra dev (2016-12-19 17:47)