Rails Load Error - incompatible library version fo

2019-08-23 03:12发布

问题:

My rails s and rails c has suddenly started refusing to boot up with the error below. I don't recall updating or deleting any gems. Any help in fixing the situation is greatly appreciated.

incompatible library version - /Users/[me]/projects/[app]/vendor/bundle/ruby/2.6.0/gems/bcrypt-3.1.12/lib/bcrypt_ext.bundle (LoadError)

bcrypt is not an explicitly required gem in our project, but it's included in Gemfile.lock because it's a dependency: bcrypt (3.1.12)

So far I've tried these, but I get the same error:

  1. Uninstalling and installing bcrypt in my system (according to this suggestion)
gem uninstall bcrypt -v 3.1.12

You have requested to uninstall the gem:
        bcrypt-3.1.12

sorcery-0.14.0 depends on bcrypt (~> 3.1)
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN]  y
Successfully uninstalled bcrypt-3.1.12
gem install bcrypt -v 3.1.12
Successfully installed bcrypt-3.1.12
  1. gem pristine --all

Here are the results of what I get if I check the gem versions:

  1. gem info bcrypt
*** LOCAL GEMS ***
bcrypt (3.1.12)
    Author: Coda Hale
    Homepage: https://github.com/codahale/bcrypt-ruby
    License: MIT
    Installed at: /Users/[me]/.rvm/gems/ruby-2.6.2

    OpenBSD's bcrypt() password hashing algorithm.
  1. bundle info bcrypt
* bcrypt (3.1.12)
        Summary: OpenBSD's bcrypt() password hashing algorithm.
        Homepage: https://github.com/codahale/bcrypt-ruby
        Path: /Users/[me]/projects/[app]/vendor/bundle/ruby/2.6.0/gems/bcrypt-3.1.12

回答1:

[RESOLVED]

[Solution 1] I needed to uninstall/reinstall the gem in the vendor/bundle folder, instead of fiddling with gem uninstall and gem install. I'd suspected this because the gems in my system should be unrelated to the gems I was using with bundler.

Here were the steps involved:

  1. Check where your gem is saved using otool -L (mine was saved here: [project root]/vendor/bundle/ruby/2.6.0/gems/bcrypt-3.1.12/lib/bcrypt_ext.bundle)

  2. Remove everything in the bcrypt-3.1.12 folder with rm -rf.

  3. bundle install --force --path vendor/bundle to reinstall the bcrypt-3.1.12 gem.

[Solution 2] What I ultimately ended up doing was to update bcrypt's version with bundle update bcrypt. Guessing this update installed the gem cleanly in vendor/bundle, because all my rails commands started working again.

bundle update bcrypt
Using bcrypt 3.1.13 (was 3.1.12)

Hope these tips help anyone who runs into this in the future!