【问题标题】:Cannot install Puma gem on Ruby on Rails无法在 Ruby on Rails 上安装 Puma gem
【发布时间】:2013-12-16 03:33:43
【问题描述】:

我正在尝试安装 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 install 安装我使用的其他gem)。

【问题讨论】:

  • 听起来您可能没有为您的平台安装 openssl 标头。查看 puma issue GH#202 以获取指向 Windows 的 OpenSSL 标头的链接。
  • 试试gem install puma --source http://rubygems.org
  • 我在bundle install 之前运行了bundle update,这解决了这个问题。我不确定这是否是唯一有帮助的,因为我手动下载了 openssl 和 gem install puma -- --with-opt-dir=c:/RailsInstaller/openssl ruby -v -ropenssl -e "puts OpenSSL::OPENSSL_VERSION"

标签: ruby-on-rails ruby-on-rails-4 rubygems puma


【解决方案1】:

想出了 puma 捆绑包的解决方案。遵循来自https://github.com/hicknhack-software/rails-disco/wiki/Installing-puma-on-windows的指示

首先你需要下载:

  • DevKit 与您的 ruby​​ 版本兼容
  • OpenSSL 开发者包(包含头文件和二进制文件)

然后:

  • 安装 DevKit,例如在c:\devkit
  • 解压 OpenSSL 包,例如在c:\openssl(使用 7Zip 或 PeaZip)
  • 您需要将 ddls 从 bin 目录(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:\opensslbundle install
  • ruby/bin 在我的系统上已经有 2 个 dll,我试图用 openssl 中的那些覆盖它们,而 ruby​​ 开始抱怨对 openssl 的支持。恢复到原始文件,一切正常,谢谢!
【解决方案2】:

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

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

  1. 通过运行ruby -v -ropenssl -e "puts OpenSSL::OPENSSL_VERSION" 检查使用的是哪个版本的 openssl Ruby
  2. 从下载正确的 openssl 版本 http://packages.openknapsack.org/openssl/openssl-1.0.0o-x86-windows.tar.lzma (从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) 很重要。
  • 这对我有用,但我不得不去寻找 64 位版本的 openssl,因为我使用的是 64 位但 Ruby 等。作为参考,我在这里找到了它:bintray.com/artifact/download/oneclick/OpenKnapsack/x64/…
【解决方案3】:

遇到了同样的问题。

sudo apt-get install libssl-dev

帮我修好了。

【讨论】:

  • OP 使用的是 windows,而不是 linux。
  • 但是,这对我很有帮助。
【解决方案4】:

我认为你遇到了问题 #430 https://github.com/puma/puma/issues/430

重新安装 Ruby 可能会对您有所帮助,并在 GitHub 上关闭了此问题。

【讨论】:

    猜你喜欢
    • 2019-03-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-21
    • 1970-01-01
    相关资源
    最近更新 更多