Eventmachine gem 安装失败

问题描述 投票:0回答:10

我无法安装 eventmachine

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

我使用

windows 8 x64
使用
ruby 2.0.0p195 (x64)
(通过适用于Windows的Ruby安装程序和适当的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 制作一个新的测试应用程序并在那里安装 Eventmachine(失败)

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

欲了解任何信息,请询问

提前谢谢大家!!

ruby eventmachine
10个回答
60
投票

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

1)尝试正常安装:

gem install eventmachine

它获取了 gem 的 1.0.3 版本,但由于变量声明冲突而导致 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 中)。

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

gem install eventmachine-1.0.3.gem --local

安装成功!


37
投票

这对我有用:

brew link openssl --force 

19
投票

尝试

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

11
投票

我收到如下错误


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

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

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

基本上,获取gem项目文件后需要一段时间才能开始编译。只需利用那段时间评论该行..它对我有用..可能不适用于每个人。

干杯!


6
投票

我遇到了同样的问题,并通过在

Gemfile
的开头添加以下内容成功运行它:

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

在此之前我卸载了

eventmachine


2
投票

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

我通过将 ruby 升级到

ruby-2.2.1
解决了这个问题。


2
投票

今天在升级到 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/


0
投票

上面关于如何编译的答案对我来说不起作用,因为我会收到“无法加载此类文件”消息。我通过从 eventmachine 存储库的 git checkout 运行

gem build eventmachine.gemspec
解决了这个问题。

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

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


0
投票

您可以在这里尝试这个答案: Rails - 无法运行应用程序:无法加载 EventMachine C 扩展;

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

按照链接中 suda 的解决方案进行操作,就可以了。

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


0
投票

我发现自己遇到了这个问题,安装后,重新安装,花了半天的时间来处理错误,最后弄清楚如何通过将 ruby 版本升级到 3.1.3 来修复它。问题已解决。

最新问题
© www.soinside.com 2019 - 2025. All rights reserved.