Read more

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

Henning Koch
December 19, 2016Software engineer at makandra GmbH

So you're getting an error like this:

undefined method `activate_bin_path' for Gem:Module (NoMethodError)
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

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

Posted by Henning Koch to makandra dev (2016-12-19 18:47)