LoadError: cannot load such file — bcrypt_ext on W

2019-02-06 04:17发布

I upgraded my environment from Ruby 2.0.0 to 2.2.3.

I also upgraded (overwrite) DevKit, and re-run ruby dk.rb install.

I removed Gemfile.lock and ran bundle install to start with a brand new environment. Everything looks ok, but I get the error:

E:\Projects\development\Stairs>rake db:migrate 
rake aborted!
LoadError: cannot load such file -- bcrypt_ext
E:/Projects/development/Stairs/config/application.rb:7:in `<top (required)>'
E:/Projects/development/Stairs/Rakefile:4:in `<top (required)>'
LoadError: cannot load such file -- 2.2/bcrypt_ext
E:/Projects/development/Stairs/config/application.rb:7:in `<top (required)>'
E:/Projects/development/Stairs/Rakefile:4:in `<top (required)>'
(See full trace by running task with --trace)

I first had the same issue with Nokogiri, which I solved using this solution : Nokogiri load error using Juloi Elixir's solution and installing Nokogiri from a local copy.

But I don't feel like doing this foreach gem! It looks like ruby is searching the gem using a ./ or ./2.2 path, while gems are stored in a ./2.2.0 path. Is this configurable? How can I solve this issue?

Note: Gemfile contains gem 'bcrypt', '~> 3.1.10'

Thanks!

9条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-02-06 04:51

Here is the solution worked for me:

    C:\> gem uninstall brcypt
    C:\> gem install --no-ri --no-rdoc bcrypt
    C:\> cd (path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri
    C:\(path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri> ruby extconf.rb
    C:\(path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri> make
    C:\(path to gems root)\bcrypt-3.1.7-x86-mingw32\ext\mri> make install
查看更多
狗以群分
3楼-- · 2019-02-06 04:53

This process is for windows:

The problem is with the programs installed on the system.

Uninstall all rails programs:

  1. All Ruby programs.

  2. RailsInstaller.

Removes all files that have been able to uninstall, you have to do it manually inside:

C:\RailsInstaller

  1. Install de ruby version 2.2 from:

http://railsinstaller.org/en

Wait a moment and it's already to go.

MarlonJon.es

查看更多
手持菜刀,她持情操
4楼-- · 2019-02-06 04:55

Solution was here: bcrypt-ruby@github:

Rebuild locally the bcrypt gem:

  1. Change to the gem directory \Ruby22-x64\lib\ruby\gems\2.2.0\gems\bcrypt-3.1.10-x64-mingw32\ext\mri>
  2. Run ruby extconf.rb
  3. Run make
  4. Run make install

Note that this works only if your DevKit environment is correctly setup (run devkitvars.bat).

查看更多
Summer. ? 凉城
5楼-- · 2019-02-06 05:03

What worked for me on Windows 7:

  1. gem uninstall bcrypt to uninstall all versions of bcrypt, including those listed as dependencies
  2. gem install bcrypt to reinstall
  3. bundle install
查看更多
可以哭但决不认输i
6楼-- · 2019-02-06 05:03

In my case, a designating of the old version to bcrypt in Gemfile was a cause of the error. I removed a designating of the version and run bundle update bcrypt, then it was settled.

查看更多
别忘想泡老子
7楼-- · 2019-02-06 05:06

I spent an entire hour fixing this, just now.

Well what I did was I followed some advice online to do a

gem install bcrypt --platform=ruby

And then, it worked in irb.

irb(main):001:0> require 'bcrypt'
=> true

Later when I had to do a bundle install, for some odd reason rails installed another bcrypt and the error was back. So I had two folders in my gem root.

bcrypt-3.1.10
bcrypt-3.1.10-x64-mingw32

So, since the first folder was the one that got built with the devkit, and it works. I deleted the contents of the second folder and copied the contents of the first into it.

Seems to be working as I'm writing this.

查看更多
登录 后发表回答