简体   繁体   English

Ruby on Windows导致错误无法加载此类文件bcrypt_ext

[英]Ruby on windows causes error Cannot load such file bcrypt_ext

Trying to run ruby on my Windows 7 machine whenever i go to rails s or rake db:migrate i get the following error Cannot load such file bcrypt_ext. 每当我去rails s或rake db:migrate时尝试在我的Windows 7机器上运行ruby我得到以下错误无法加载这样的文件bcrypt_ext。

My ruby version is 2.2.1 my rails version is 4.2.0 and the bcrypt version is 3.1.10. 我的ruby版本是2.2.1我的rails版本是4.2.0而bcrypt版本是3.1.10。 All the gems install correctly when i run bundle install however whenever i try to rake it gives me that error. 当我运行bundle install时,所有的gem都正确安装,但是每当我尝试rake它时都会给我这个错误。 Any help would be greatly appreciated 任何帮助将不胜感激

You need to use what it says here: https://www.alib.jp/entries/bcrypt_ext_load_error_on_ruby21x 你需要使用它在这里说的内容: https//www.alib.jp/entries/bcrypt_ext_load_error_on_ruby21x

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

For Windows 10, bcrypt 3.1.11 now works, checked in 24144 对于Windows 10,bcrypt 3.1.11现在可以使用, 在24144中检查

steps: 脚步:

  1. shut down all rails servers 关闭所有rails服务器
  2. uninstall all versions of bcrypt 卸载所有版本的bcrypt
  3. manually install v3.1.1 ( gem install bcrypt -v '3.1.11' ) 手动安装v3.1.1( gem install bcrypt -v '3.1.11' -v'3.1.11 gem install bcrypt -v '3.1.11'
  4. update gem files of projects 更新项目的gem文件

current versions 当前版本

  • ruby 2.2.4p230 (2015-12-16 revision 53155) [i386-mingw32] ruby 2.2.4p230(2015-12-16修订版53155)[i386-mingw32]

  • OS Name: Microsoft Windows 10 Pro 操作系统名称:Microsoft Windows 10 Pro

  • OS Version: 10.0.10586 N/A Build 10586 操作系统版本:10.0.10586不适用Build 10586

The dirty quick workaround is to install the mri version with 脏的快速解决方法是安装mri版本

gem install bcrypt --platform=ruby

worked for me. 为我工作。

Fetching: bcrypt-3.1.11.gem (100%) Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... Successfully installed bcrypt-3.1.11

source: topac commented on Apr 17, 2015 https://github.com/codahale/bcrypt-ruby/issues/116 来源: topac评论于2015年4月17日https://github.com/codahale/bcrypt-ruby/issues/116

I meet the same problem in Window 8.1 64bit , Ruby 2.3.3 64bit , Rails 4.2.10. 我在Window 8.1 64bit,Ruby 2.3.3 64bit,Rails 4.2.10中遇到了同样的问题。

My quick solution : 我的快速解决方案

Step 1 : Remove all bcrypt in gem : gem uninstall bcrypt ( choose option 3 if existed (remove all)) 步骤1:删除gem中的所有bcrypt: gem uninstall bcrypt (如果存在则选择选项3(全部删除))

Step 2 : Install bcrypt again : gem install bcrypt 第2步:再次安装bcrypt: gem install bcrypt

Then check version of bcrypt : gem list bcrypt 然后检查bcrypt: gem list bcrypt

Step 3 : In Gemfile of your project, add : gem 'bcrypt', '3.1.11', platforms: [:ruby, :x64_mingw] notice : change the suitable version of your bcrypt (my version : 3.1.11) 第3步:在你的项目的Gemfile中,添加:gem'bcrypt gem 'bcrypt', '3.1.11', platforms: [:ruby, :x64_mingw]注意:更改你的bcrypt的合适版本(我的版本:3.1.11)

Step 4 : Run command in the path of your project : bundle install 第4步:在项目路径中运行命令: bundle install

Step 5 : Remove the unneeded bcrypt : Run command : gem uninstall bcrypt You can see some version of bcrypt , you should keep one version : bcrypt-[your-version] . 步骤5:删除不需要的bcrypt:运行命令: gem uninstall bcrypt你可以看到某个版本的bcrypt,你应该保留一个版本:bcrypt- [your-version]。 (Remove all version : bcrypt-[your-version]-x64-mingw32 . In mycase , remove : bcrypt-3.1.11-x64-mingw32) (删除所有版本:bcrypt- [your-version] -x64-mingw32。在mycase中,删除:bcrypt-3.1.11-x64-mingw32)

Restart Rails sever , done 重新启动Rails服务器,完成

I think this proplem because when we install bcrypt , we didn't specify 64bit or 32bit , it is not compatible with window or ruby ( 64bit or 32bit ) 我认为这个问题是因为当我们安装bcrypt时,我们没有指定64bit或32bit,它与窗口或ruby(64bit或32bit)不兼容

Most likely the compiled gem binaries don't contain binaries for Ruby 2.2.1 . 很可能编译的gem二进制文件不包含Ruby 2.2.1二进制文件。 This is because there is a problem with cross-compiling Ruby with a Windows target. 这是因为使用Windows目标交叉编译Ruby存在问题。 See this answer for more details. 有关详细信息,请参阅此答案

The best alternative is to downgrade to Ruby 2.1.5 . 最好的选择是降级到Ruby 2.1.5

You can try to compile the gem yourself, but that's a totally different beast. 您可以尝试自己编译宝石,但这是一个完全不同的野兽。 In some cases, like nokogiri , it's not even possible. 在某些情况下,就像nokogiri一样,它甚至都不可能。

Rich Peck solution worked for me with a small update. Rich Peck解决方案为我提供了一个小小的更新。 Make sure the devkit is included in the environment path.(Check it by typing path in the command prompt) If its not included,you need to add the devkit/bin and devkit/mingw/bin paths to your PATH var. 确保devkit包含在环境路径中。(通过在命令提示符中键入path来检查它)如果未包含它,则需要将devkit / bin和devkit / mingw / bin路径添加到PATH var。

Otherwise - make: x86_64-w64-mingw32-gcc: Command not found - error will be thrown while you make the file. 否则 - make:x86_64-w64-mingw32-gcc:找不到命令 - 在创建文件时将抛出错误。

Once the error is fixed, then i am able to make the file and the bcrypt_ext issue is solved. 一旦错误得到修复,我就可以使文件和bcrypt_ext问题得到解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM