Fix Rubygems binary error: undefined method `activate_bin_path' for Gem:Module (NoMethodError)

Updated . Posted . Visible to the public.

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 or rails) 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 or gem install.

Also see: When upgrading/downgrading RubyGems and Bundler on a server, you must clear bundled gems

Henning Koch
Last edit
Arne Hartherz
Keywords
binstubs
License
Source code in this card is licensed under the MIT License.
Posted by Henning Koch to makandra dev (2016-12-19 17:47)