[英]LoadError: cannot load such file — bcrypt
I am trying to use bcrypt to secure users password, but when i am creating new user in database i receive this error: "LoadError: cannot load such file -- bcrypt" 我试图使用bcrypt来保护用户密码,但是当我在数据库中创建新用户时,我收到此错误:“ LoadError:无法加载此类文件-bcrypt”
what i did till now: 我到目前为止所做的:
i have placed a gem in the Gemfile gem 'bcrypt', '3.1.11'
我已经在Gemfile gem'bcrypt gem 'bcrypt', '3.1.11'
放置了gem
i installed it sudo bundler install
我安装了sudo bundler install
bcrypt is in the gem list bcrypt在宝石列表中
$ gem list bcrypt *** LOCAL GEMS *** bcrypt (3.1.11)
sudo service apache2 restart sudo服务apache2重新启动
$ rails console Running via Spring preloader in process 21100 Loading development environment (Rails 5.1.0) irb(main):001:0> User.create(username: "user1" , password: "pass123", password_confirmation: "pass123") You don't have bcrypt installed in your application. Please add it to your Gemfile and run bundle install LoadError: cannot load such file -- bcrypt from app/models/user.rb:2:in `<class:User>' from app/models/user.rb:1:in `<top (required)>' from (irb):1
And as you see it didn't work! 如您所见,它不起作用!
i tried to uninstall and install bcrypt again => same result 我试图再次卸载并安装bcrypt =>同样的结果
i have tried other version of bcrypt => same result 我尝试过其他版本的bcrypt =>相同的结果
bcrypt-ruby
to gems => same result 我将bcrypt-ruby
添加到gems =>相同的结果 install bcrypt --platform=ruby
and gem 'bcrypt-ruby', '3.1.5', :require => 'bcrypt'
=> same result 我用gem install bcrypt --platform=ruby
和install bcrypt --platform=ruby
gem 'bcrypt-ruby', '3.1.5', :require => 'bcrypt'
=>相同的结果 cd [path to gems folder]/gems/bcrypt-ruby-2.1.4/ext/mri ruby extconf.rb make sudo make install
=> same result =>同样的结果
Thank you in advance for your help. 预先感谢您的帮助。 I hope this question, with your answers will help people with same problem in future 我希望这个问题以及您的回答将对以后有同样问题的人们有所帮助
I solved the problem. 我解决了问题。 i was searching for it almost 2 days! 我一直在寻找它将近2天!
kill all the processes with name spring using the pkill command as follows: 使用pkill命令杀死所有名称为spring的进程,如下所示:
$ pkill -15 -f spring
open a new terminal and : bundle exec guard is it gave you error "bundler: command not found: guard" dont worry. 打开一个新的终端,然后:bundle exec guard是它给了你错误“ bundler:找不到命令:guard”,不用担心。 just be sure you have installed bycrypt by gem list bcrypt
install bundle 只要确保您已按gem list bcrypt
install bundle安装了bycrypt
sudo bundle install
then restart your server 然后重新启动服务器
sudo service apache2 restart
now it works! 现在可以了!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.