Rails 加载错误 - bcrypt 的库版本不兼容

ree*_*ces 0 ruby rubygems ruby-on-rails bcrypt

我的rails s电脑rails c突然开始拒绝启动,并出现以下错误。我不记得更新或删除过任何宝石。非常感谢任何帮助解决这种情况的帮助。

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

bcrypt不是我们项目中明确需要的 gem,但它包含在其中,Gemfile.lock因为它是一个依赖项:bcrypt (3.1.12)

到目前为止我已经尝试过这些,但我得到了同样的错误:

  1. 在我的系统中卸载和安装bcrypt(根据此建议
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
Run Code Online (Sandbox Code Playgroud)
gem install bcrypt -v 3.1.12
Successfully installed bcrypt-3.1.12
Run Code Online (Sandbox Code Playgroud)
  1. gem pristine --all

以下是检查 gem 版本时得到的结果:

  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.
Run Code Online (Sandbox Code Playgroud)
  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
Run Code Online (Sandbox Code Playgroud)

ree*_*ces 7

[解决]

[解决方案1]我需要卸载/重新安装文件夹中的gem vendor/bundle,而不是执行gem uninstallgem install

以下是所涉及的步骤:

  1. 使用检查你的宝石保存在哪里otool -L(我的宝石保存在这里[project root]/vendor/bundle/ruby/2.6.0/gems/bcrypt-3.1.12/lib/bcrypt_ext.bundle:)

  2. 删除bcrypt-3.1.12文件夹中的所有内容rm -rf

  3. bundle install --force --path vendor/bundle重新安装bcrypt-3.1.12gem。

[解决方案2]我最终所做的是将 的bcrypt版本更新为bundle update bcrypt. 猜测此更新将 gem 干净地安装在 中vendor/bundle,因为我的所有rails命令再次开始工作。

bundle update bcrypt
Using bcrypt 3.1.13 (was 3.1.12)
Run Code Online (Sandbox Code Playgroud)

希望这些提示对将来遇到此问题的人有所帮助!