问题描述
我的rails s
和rails c
突然开始拒绝启动,并出现以下错误.我不记得要更新或删除任何宝石.在解决该问题方面提供的任何帮助都将受到赞赏.
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
不是我们项目中明确需要的gem,但它包含在Gemfile.lock
中,因为它是一个依赖项:bcrypt (3.1.12)
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:
- 在我的系统中卸载和安装
bcrypt
(根据此建议)
- 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
-
gem pristine --all
这是我检查gem版本后得到的结果:
Here are the results of what I get if I check the gem versions:
-
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.
-
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] ,我需要在vendor/bundle
文件夹中卸载/重新安装gem,而不是执行gem uninstall
和gem install
.
[Solution 1] I needed to uninstall/reinstall the gem in the vendor/bundle
folder, instead of doing gem uninstall
and gem install
.
以下是其中涉及的步骤:
Here were the steps involved:
-
使用
otool -L
检查您的宝石保存在哪里(我的宝石保存在这里:[project root]/vendor/bundle/ruby/2.6.0/gems/bcrypt-3.1.12/lib/bcrypt_ext.bundle
)
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
)
使用rm -rf
删除bcrypt-3.1.12
文件夹中的所有内容.
Remove everything in the bcrypt-3.1.12
folder with rm -rf
.
bundle install --force --path vendor/bundle
重新安装bcrypt-3.1.12
gem.
[解决方案2] ,我最终要做的是用bundle update bcrypt
更新bcrypt
的版本.猜测此更新可以在vendor/bundle
中干净地安装了gem,因为我的所有rails
命令都可以再次开始工作.
[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!
这篇关于Rails加载错误-bcrypt的库版本不兼容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!