在 Windows 上安装 bcrypt-ruby gem
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1666511/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Installing bcrypt-ruby gem on Windows
提问by Jaryl
I'm trying to install bcrypt-rubyon Windows Vista.
我正在尝试在 Windows Vista 上安装bcrypt-ruby。
So far, I have been able to install nmake.exe from a MS knowledge base article and cl.exe from installing Visual Studio 2008 Express.
到目前为止,我已经能够从 MS 知识库文章中安装 nmake.exe,并从安装 Visual Studio 2008 Express 中安装 cl.exe。
However, I am now encountering this error:
但是,我现在遇到了这个错误:
cl -nologo -Wall -I. -IC:/InstantRails/ruby/lib/ruby/1.8/i386-mswin32 -I
C:/InstantRails/ruby/lib/ruby/1.8/i386-mswin32 -I. -MD -Zi -O2b2xg- -G6 -c -Tcb crypt.c
cl : Command line warning D9035 : option 'Og-' has been deprecated and will be removed in a future release
cl : Command line warning D9002 : ignoring unknown option '-G6' bcrypt.c
C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\stdio.h(381) : warning C4255: '_get_printf_count_output' : no function prototype given: converting '()' to '(void)'
C:\Program Files\Microsoft Visual Studio 9.0\VC\INCLUDE\stdlib.h(215) : warning C4255: '_get_purecall_handler' : no function prototype given: converting '()' to '(void)'
c:\instantrails\ruby\lib\ruby\gems.8\gems\bcrypt-ruby-2.1.2\ext\mri\blf.h(37): fatal error C1083: Cannot open include file: 'stdint.h': No such file or directory
NMAKE : fatal error U1077: '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.EXE"' : return code '0x2' Stop.
I've already executed VCVARS32.bat which presumably sets up the environment. I am suspecting that the warnings and errors are due to installing newer version of Visual Studio.
我已经执行了 VCVARS32.bat,它大概设置了环境。我怀疑警告和错误是由于安装了较新版本的 Visual Studio。
Has anyone done this successfully? I do not have a copy of Visual Studio 6.0.
有没有人成功地做到了这一点?我没有 Visual Studio 6.0 的副本。
回答by giorgian
The better, easiest way is to install the development kit:
更好、最简单的方法是安装开发工具包:
- Download
devkit-<version>.7z
from here; - unpack it in the Ruby directory (for instance,
C:\Ruby
, so that you'll haveC:\Ruby\devkit
; - from command line, type:
gem install bcrypt-ruby
.
devkit-<version>.7z
从这里下载;- 将它解压到 Ruby 目录中(例如,
C:\Ruby
,这样你就会有C:\Ruby\devkit
; - 从命令行,键入:
gem install bcrypt-ruby
。
回答by Luis Lavena
To be able to build a gem extension for One-Click Installer (OCI) you need VC6. Mxing and matching different versions of newer Visual Studio will fail or will generate unknown errors during runtime.
为了能够为一键安装程序 (OCI) 构建 gem 扩展,您需要 VC6。混合和匹配不同版本的较新 Visual Studio 将失败或在运行时生成未知错误。
I would recommend avoid all these hassles and proceed with the successor of One-Click, which is called RubyInstaller.
我建议避免所有这些麻烦并继续使用称为 RubyInstaller 的 One-Click 的继任者。
- Download and install either 1.8.6 or 1.9.1 RC1 packages, announced at RubyForge
- Download the Development Kit, and unpack it on your Ruby installation
- Follow
INSTALL.txt
instructions to adjust the DevKit to the location you extracted it - Proceed with
gem install bcrypt-ruby
, will work out of the box
- 下载并安装 1.8.6 或 1.9.1 RC1 包,在 RubyForge 上发布
- 下载开发工具包,并将其解压到您的 Ruby 安装中
- 按照
INSTALL.txt
说明将 DevKit 调整到您提取它的位置 - 继续
gem install bcrypt-ruby
,开箱即用
For more details about using other gems or Rails with this newer version, please see the tutorialssection in our Wiki.
有关在此较新版本中使用其他 gem 或 Rails 的更多详细信息,请参阅我们 Wiki 中的教程部分。
Hope this helps.
希望这可以帮助。
回答by eamo
For me, the following worked
对我来说,以下工作
gem uni bcrypt-ruby
gem i bcrypt-ruby --platform=ruby
回答by AMIC MING
Try below command
试试下面的命令
gem install bcrypt-ruby --platform=mswin32
gem install bcrypt-ruby --platform=mswin32
回答by u445908
I met the same problem when installing devise in windows.
我在 Windows 中安装设备时遇到了同样的问题。
maybe you could checkout this: http://github.com/oneclick/rubyinstaller/wiki/development-kit
也许你可以看看这个:http: //github.com/oneclick/rubyinstaller/wiki/development-kit
and giorgian is correct, pay attention here:
和 giorgian 是正确的,请注意这里:
ruby version: you must install the "ruby installer" version, but not .zip version or other version.
unpack it in the Ruby directory (for instance, C:\Ruby, so that you'll have C:\Ruby\devkit;
If you installed ruby from other setup file (which is not ruby-installer), you MUST remove it ,then install ruby with the ruby installer. don't simply overwrite it.
no need to install VC6, it won't work with other ruby setup version(which is not ruby- installer) . if you installed it just for setup the ruby-gem, I suggest you remove it.
no need to install MinGW , cause dev-kit is based on it.
ruby 版本:您必须安装“ruby installer”版本,而不是 .zip 版本或其他版本。
将它解压到 Ruby 目录中(例如,C:\Ruby,这样你就会有 C:\Ruby\devkit;
如果您从其他安装文件(不是 ruby-installer)安装了 ruby,则必须将其删除,然后使用 ruby 安装程序安装 ruby。不要简单地覆盖它。
无需安装 VC6,它不适用于其他 ruby 安装版本(不是 ruby-installer)。如果您安装它只是为了设置 ruby-gem,我建议您将其删除。
无需安装 MinGW ,因为 dev-kit 是基于它的。
I spent almost 15 hours to solve this problem. and it's now time to say that "ruby-installer" + "dev kit" is our choise to build the native gem.
我花了将近 15 个小时来解决这个问题。现在是时候说“ruby-installer”+“dev kit”是我们构建原生 gem 的选择。
回答by gamov
On Windows Server 2003 (Ruby 1.8.6), the plain vanilla:
在 Windows Server 2003 (Ruby 1.8.6) 上,普通版本:
gem install bcrypt-ruby
worked like a charm.
Note that if you want to use it with Rails, you must use:
像魅力一样工作。
请注意,如果要与 Rails 一起使用,则必须使用:
config.gem 'bcrypt-ruby', :lib => 'bcrypt'
回答by Rdebokx
For me, a part of the problem was in the fact that I had Ruby2.0.0 x64 installed (I'm running win8), which seemed to be incompatible with the gcc compiler I was using.
对我来说,部分问题在于我安装了 Ruby2.0.0 x64(我运行的是 win8),这似乎与我使用的 gcc 编译器不兼容。
I've removed my ruby installation, and installed ruby 1.9.3 together with Bundler, Rails and some other packages with the use railsInstaller (http://railsinstaller.org/) and I'm now able to install bcrypt-ruby :)
我已经删除了我的 ruby 安装,并使用 railsInstaller ( http://railsinstaller.org/)将 ruby 1.9.3 与 Bundler、Rails 和一些其他软件包一起安装,我现在可以安装 bcrypt-ruby :)