【问题标题】:Eventmachine gem install failEventmachine gem 安装失败
【发布时间】:2013-06-26 01:33:14
【问题描述】:

我无法安装 eventmachine

好的,我知道这个问题已经问了很多了,但是到目前为止我没有找到任何解决方案对我有帮助。所以我在最后的手段上发布了这里。

我使用 windows 8 x64 使用ruby 2.0.0p195 (x64)(通过适用于 Windows 的 Ruby Installer 和适当的 Devkit 安装)

所以错误

    Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension
C:/Ruby200-x64/bin/ruby.exe extconf.rb
checking for main() in -lssl... no
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... yes
checking for inotify_init() in sys/inotify.h... no
checking for __NR_inotify_init in sys/syscall.h... no
checking for writev() in sys/uio.h... no
checking for rb_wait_for_single_fd()... yes
checking for rb_enable_interrupt()... no
checking for rb_time_new()... yes
checking for windows.h... yes
checking for winsock.h... yes
checking for main() in -lkernel32... yes
checking for main() in -lrpcrt4... yes
checking for main() in -lgdi32... yes
creating Makefile

make
generating rubyeventmachine-x64-mingw32.def
compiling binder.cpp
In file included from c:\users\btdy\downloads\devkit\mingw\bin\../lib/gcc/x86_64
-w64-mingw32/4.7.2/../../../../x86_64-w64-mingw32/include/process.h:12:0,
             from c:/Ruby200-x64/include/ruby-2.0.0/ruby/win32.h:60,
             from c:/Ruby200-x64/include/ruby-2.0.0/ruby/defines.h:153,
             from c:/Ruby200-x64/include/ruby-2.0.0/ruby/ruby.h:70,
             from c:/Ruby200-x64/include/ruby-2.0.0/ruby.h:33,
             from em.h:24,
             from project.h:150,
             from binder.cpp:20:
c:\users\btdy\downloads\devkit\mingw\bin\../lib/gcc/x86_64-w64-mingw32/4.7.2/../
../../../x86_64-w64-mingw32/include/sys/types.h:68:16: error: conflicting declar
ation 'typedef _pid_t pid_t'
In file included from binder.cpp:20:0:
project.h:97:13: error: 'pid_t' has a previous declaration as 'typedef int pid_t
'
In file included from project.h:151:0,
             from binder.cpp:20:
ed.h: In member function 'void EventableDescriptor::SetSocketInvalid()':
ed.h:43:40: warning: overflow in implicit constant conversion [-Woverflow]
make: *** [binder.o] Error 1      

我尝试过的事情gem "eventmachine", "~> 1.0.3"gem "eventmachine", "~> 1.0.0.beta.4.1" 放入我的 gemfile 并从 gemfile.lock 删除/修改 eventmachine 制作一个新的 testapp 并在那里安装 Eventmachine(失败)

我怀疑的事情我追踪了 eventmachine 的依赖项(可以在 Rubygems 上找到),我发现我也无法安装 bluecloth(显示更大的日志错误),我也无法安装 @ 987654322@(bluecloth 依赖)所以我认为它可能有一些相关性,也不能安装薄

任何信息都可以问

提前谢谢大家!!

【问题讨论】:

  • 这看起来像是 github 上报告的问题。我能找到的最好的方法是尝试从 github 克隆最新的 eventmachine 并使用它进行构建:groups.google.com/forum/#!topic/rubyinstaller/uCHtdKuuOPY/…
  • @Casper 谢谢你,我会努力解决的:)
  • 甚至像Ruby 2.0.0-p247 (x64)这样的新版本也会受到这个问题的影响

标签: ruby eventmachine


【解决方案1】:

我可以安装它,执行以下步骤:

1) 尝试正常安装:

gem install eventmachine

它获取了 gem 的 1.0.3 版本,但由于变量声明 conflit,在 make 中失败

2) 编辑文件:

c:\Ruby200-x64\lib\ruby\gems\2.0.0\gems\eventmachine-1.0.3\ext\project.h

并评论了第 97 行

//typedef int pid_t;

如需更稳健的修正,请在此处查看解决方案 https://github.com/eventmachine/eventmachine/pull/450/files

3) 然后,我打开了命令提示符,然后转到 gem 文件夹

c:\Ruby200-x64\lib\ruby\gems\2.0.0\gems\eventmachine-1.0.3

然后运行:

gem build eventmachine.gemspec

您需要在 PATH 中使用 git.exe 位置安装 git 才能使其正常工作(例如 C:\Users\YourUsername\AppData\Local\GitHub\PORTAB~1\bin)。

4) 它在文件夹中生成了一个 eventmachine.gem 文件...所以我将一个文件复制到 c:\tmp 文件夹,然后转到该文件夹​​并从那里输入:

gem install eventmachine-1.0.3.gem --local

并且安装成功!

【讨论】:

  • 自从 Windows 开始吓坏我以来,我一直在使用 Ubuntu :P,当我登录 Windows 时,我一定会尝试 :)
  • 它有效!但这会不会导致事件机器出现问题,比如这个错误? ..'require': cannot load such file -- eventmachine (LoadError)
  • 为我确认的解决方案,非常感谢。如果我看到像 @Mobiletainment 那样的任何错误,我一定会及时通知您。
  • 是的 - 得到与上述相同的错误。 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/thin-1.6.1/lib/thin.rb:7:in 'require': cannot load such file -- eventmachine (LoadError)
  • 修复已合并到 eventmachine master 分支。从 git repo 中获取 gem,就像 gem 'eventmachine', '1.0.3', :git => "git://github.com/eventmachine/eventmachine.git"..这对我有用
【解决方案2】:

我收到如下错误


C:\Ruby200-x64\lib\ruby\gems\2.0.0\gems\eventmachine-1.0.3>gem build eventmachine.gemspec [eventmachine.gemspec] 中的无效 gemspec:没有这样的文件或目录 - git ls-files

错误:加载 gemspec 时出错。中止。

但是,我在 textpad 中打开了 project.h 并尝试执行 gem install eventmachine。在某一时刻,textpad 将要求确认重新加载 project.h,因为新文件是从 gem install 命令获取的。只需重新加载并注释行 //typedef int pid_t;.. 然后编译通过..

基本上,在获取 gem 项目文件后开始编译需要一段时间。只需利用这段时间来评论 htis 行。它对我有用。可能并不适合所有人。

干杯!

【讨论】:

  • 哈哈,很聪明。只需确保注释掉typedef int pid_t; 并尽可能快地保存文件。在编译器读取文件之前完成它。
  • 非常好,我使用了 Notepad++,当它询问我是否要重新加载时,我说不,然后按 ctrl+s 将文件版本保存在编辑器中,因为我已经将第 97 行注释掉了,并且成功了。
【解决方案3】:

上面关于如何编译的答案对我不起作用,因为我会收到“无法加载此类文件”消息。我通过从 eventmachine repo 的 git checkout 运行 gem build eventmachine.gemspec 解决了这个问题。

https://github.com/eventmachine/eventmachine/tree/v1.0.3

您应该能够看到 .gem 文件的大小要大得多,因为它实际上包含了正确的代码。

【讨论】:

    【解决方案4】:

    你可以在这里试试这个答案: Rails - cannot run app: Unable to load the EventMachine C extension;

    此问题的已接受答案有效。但是您会遇到其他问题,如下面的 cmets 所示。

    按照链接中suda的解决方案,你会没事的。

    (实际上,它基本上是从主 github 代码库编译和安装 gem。我很惊讶他们还没有将问题修复推送到 master,因为他们知道这一点。)

    【讨论】:

      【解决方案5】:

      我遇到了同样的问题,并通过在Gemfile的开头添加以下内容成功运行它:

      gem 'eventmachine', :git => 'git://github.com/eventmachine/eventmachine.git', :branch => 'master'
      

      在此之前我卸载了eventmachine

      【讨论】:

      • 这对我有用。我在开头添加了事件机器 gem 行(我试图安装 barkeep)
      • 在 Heroku 的新 Docker 设置环境中,这对我也很有效。事件机器出现故障,添加到顶部,我的容器能够启动。谢谢!
      • 也适合我。 Apple Silicon M1 上的 Rails 6.1。
      【解决方案6】:

      我今天在升级到 Ruby 2.2.0 时遇到了 eventmachine gem(版本 1.0.3 和 1.0.4)的类似问题。我通过为 MAC OSX 10.10.1 Yosemite 和 XCode 6.1.1 安装最新的“开发者工具”来修复它

      这是我的详细博客文章,用于解决 eventmachine gem 安装问题 - https://blog.kiprosh.com/upgrading-to-ruby-2-2-0-issues-installing-gem-eventmachine/

      【讨论】:

      • 与 OS 10.8.5 相同的体验 - 将 XCode 从 v5 升级到 6.3,解决了这个问题。
      【解决方案7】:

      这对我有用:

      brew link openssl --force 
      

      【讨论】:

      • 这对我有用,因为我有这个错误Installing eventmachine 0.12.10 with native extensions Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb checking for rb_trap_immediate in ruby.h,rubysig.h... no checking for sys/queue.h... yes creating Makefile make "DESTDIR=" compiling binder.cpp In file included from binder.cpp:20: ./project.h:103:10: fatal error: 'openssl/ssl.h' file not found #include <openssl/ssl.h> ^ 1 error generated. make: *** [binder.o] Error 1
      • 这对我来说就像一个魅力,所以这是我的一票!
      • 这在 2k18 中不起作用。使用那个答案 - stackoverflow.com/a/42619738/1514072
      【解决方案8】:

      我在 linux 中遇到了同样的问题。

      我通过将 ruby​​ 升级到 ruby-2.2.1 解决了这个问题。

      【讨论】:

        【解决方案9】:

        试试

        gem install eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2013-02-24
          • 2012-09-26
          • 2011-08-13
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多