无法在Ruby on Rails上安装Puma gem

23

我正试图安装puma gem,但当我运行

gem install puma

我收到了这个错误信息:

Temporarily enhancing PATH to include DevKit
Building native extensions.  This could take a while...
ERROR:  Error installing puma:
        ERROR: Failed to build gem native extension.

    C:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile

make                                                
generating puma_http11-i386-mingw32.def                              
compiling http11_parser.c       
ext/http11/http11_parser.rl: In function 'puma_parser_execute':  
ext/http11/http11_parser.rl:111:3: warning: comparison between signed and unsigned integer   expressions    
compiling io_buffer.c   
io_buffer.c: In function 'buf_to_str':             
io_buffer.c:119:3: warning: pointer targets in passing argument 1 of 'rb_str_new'      differ in signedness             
c:/Ruby193/include/ruby-1.9.1/ruby/intern.h:653:7: note: expected 'const char *' but argument is of type 'uint8_t *'                    
compiling mini_ssl.c                                         
In file included from mini_ssl.c:3:0:                                        
c:/Ruby193/include/ruby-1.9.1/ruby/backward/rubyio.h:2:2: warning: #warning use "ruby/io.h" instead of "rubyio.h"              
mini_ssl.c:4:25: fatal error: openssl/bio.h: No such file or directory               
compilation terminated.                     
make: *** [mini_ssl.o] Error 1             

Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/puma-2.6.0 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/puma-2.6.0/ext/puma_http11/gem_make.out

gem 'puma'添加到我的Gemfile并运行bundle install不是一个选项,因为它不能与任何gem一起使用,并给我一个错误消息(这是一个单独的问题,我已经通过安装其他gem来绕过它们gem install)。


3
听起来你可能没有在你的平台上安装openssl头文件。请查看puma问题GH#202,以获取Windows的OpenSSL头文件链接。 - nbrew
尝试运行 gem install puma --source http://rubygems.org 进行安装。 - Gopal S Rathore
1
我在运行bundle install之前先运行了bundle update,这解决了问题。我不确定这是唯一有帮助的事情,因为我手动下载了openssl并且运行了gem install puma -- --with-opt-dir=c:/RailsInstaller/opensslruby -v -ropenssl -e "puts OpenSSL::OPENSSL_VERSION" - Anis Abboud
4个回答

15

我遇到了相同的问题。

sudo apt-get install libssl-dev

对我有帮助,解决了我的问题。


3
原文:The OP is using windows, not linux. 翻译:原帖作者使用的是Windows系统,而不是Linux系统。 - Seiyria
7
但是,这对我很有帮助。 - hayesgm

12

在运行bundle install之前,我运行了bundle update,这解决了我的问题。

我不确定这是否是唯一有帮助的事情,因为在那之前我手动更新了puma,使用了以下步骤:

  1. 运行ruby -v -ropenssl -e "puts OpenSSL::OPENSSL_VERSION"检查 Ruby 正在使用哪个版本的 openssl。
  2. http://packages.openknapsack.org/openssl/openssl-1.0.0o-x86-windows.tar.lzma下载正确的 openssl 版本(从https://github.com/hicknhack-software/rails-disco/wiki/Installing-puma-on-windows获取链接,并根据第 1 步的输出进行编辑)。
  3. 使用http://www.7-zip.org将 openssl 解压到 C:\RailsInstaller\openssl。
  4. gem install puma -- --with-opt-dir=C:/RailsInstaller/openssl

我认为这是手动更新的原因。我按照那些步骤做了,它起作用了。请注意,重要的是要使用正斜杠(C:/RailsInstaller/openssl)而不是反斜杠(C:\RailsInstaller\openssl)。 - Eva
1
这对我有用,但是由于我使用的是64位Ruby等,所以我不得不去寻找64位版本的openssl。供参考,我在这里找到了它:https://bintray.com/artifact/download/oneclick/OpenKnapsack/x64/openssl-1.0.1l-x64-windows.tar.lzma - Taz

6

解决了Puma捆绑包的问题。按照https://github.com/hicknhack-software/rails-disco/wiki/Installing-puma-on-windows上的说明进行操作。

首先,你需要下载以下内容:

然后:

  • 安装DevKit,例如在 c:\devkit 目录下
  • 解压OpenSSL包,例如在 c:\openssl 目录下(使用7Zip或PeaZip)
  • 你需要将bin目录中的dll文件(libeay32.dllssleay32.dll)复制到你的ruby/bin目录下。
  • 打开Windows控制台
  • 初始化DevKit构建环境:c:\devkit\devkitvars.bat(除此之外,我在命令提示符中使用了这个命令:ruby dk.rb init

现在,可以使用OpenSSL包安装Puma gem:

gem install puma -- --with-opt-dir=c:\openssl

这个解决方案对我很有效。以防万一,如果有人需要详细说明: gem install puma -v'2.9.1' -- --with-opt-dir=c:\openssl bundle install - Seto
ruby/bin已经有了我系统上的2个dll文件,我试图用openssl中的文件覆盖它们,结果ruby开始抱怨openssl支持的问题。恢复到原始文件后一切正常,谢谢! - cipak

3

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接