在OSX Yosemite上安装EventMachine gem时出错

时间:2014-12-30 03:48:40

标签: ruby-on-rails ruby gcc osx-yosemite eventmachine

以下是错误消息的完整输出:

    Fetching: eventmachine-1.0.3.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing eventmachine:
    ERROR: Failed to build gem native extension.

    /Users/Tyler/.rvm/rubies/ruby-2.2.0/bin/ruby -r ./siteconf20141229-47086-wfdm3m.rb extconf.rb
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... no
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... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_enable_interrupt()... no
checking for rb_time_new()... yes
checking for sys/event.h... yes
checking for sys/queue.h... yes
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling binder.cpp
compiling cmain.cpp
compiling ed.cpp
compiling em.cpp
em.cpp:827:9: error: use of undeclared identifier 'rb_thread_select'; did you mean 'rb_thread_fd_select'?
        return EmSelect (maxsocket+1, &fdreads, &fdwrites, &fderrors, &tv);
               ^~~~~~~~
               rb_thread_fd_select
./em.h:25:20: note: expanded from macro 'EmSelect'
  #define EmSelect rb_thread_select
                   ^
/Users/Tyler/.rvm/rubies/ruby-2.2.0/include/ruby-2.2.0/ruby/intern.h:454:5: note: 'rb_thread_fd_select' declared here
int rb_thread_fd_select(int, rb_fdset_t *, rb_fdset_t *, rb_fdset_t *, struct timeval *);
    ^
em.cpp:827:32: error: cannot initialize a parameter of type 'rb_fdset_t *' with an rvalue of type 'fd_set *'
        return EmSelect (maxsocket+1, &fdreads, &fdwrites, &fderrors, &tv);
                                      ^~~~~~~~
/Users/Tyler/.rvm/rubies/ruby-2.2.0/include/ruby-2.2.0/ruby/intern.h:454:42: note: passing argument to parameter here
int rb_thread_fd_select(int, rb_fdset_t *, rb_fdset_t *, rb_fdset_t *, struct timeval *);
                                         ^
em.cpp:946:6: error: use of undeclared identifier 'rb_thread_select'; did you mean 'rb_thread_fd_select'?
                                        EmSelect (0, NULL, NULL, NULL, &tv);
                                        ^~~~~~~~
                                        rb_thread_fd_select
./em.h:25:20: note: expanded from macro 'EmSelect'
  #define EmSelect rb_thread_select
                   ^
/Users/Tyler/.rvm/rubies/ruby-2.2.0/include/ruby-2.2.0/ruby/intern.h:454:5: note: 'rb_thread_fd_select' declared here
int rb_thread_fd_select(int, rb_fdset_t *, rb_fdset_t *, rb_fdset_t *, struct timeval *);
    ^
3 errors generated.
make: *** [em.o] Error 1

make failed, exit code 2

之前有没有人看过这样的错误?我有命令行工具 - 从来没有遇到过在我的旧笔记本电脑上运行优胜美地时编译这个宝石的错误。

7 个答案:

答案 0 :(得分:47)

EventMachine 1.0.3 didn’t work with Ruby 2.2。这已在EventMachine 1.0.4中修复。您最有可能通过使用

升级EventMachine来修复您的情况
bundle update eventmachine

答案 1 :(得分:42)

对于El Captain来说,这对我有用:

$ bundle update eventmachine # updated to v1.0.8
$ bundle config build.eventmachine --with-cppflags=-I/usr/local/opt/openssl/include
$ bundle install

答案 2 :(得分:13)

如果您有brew安装,请尝试

brew install openssl

如果仍然说,

Warning: openssl-1.0.2e already installed

然后运行此命令,

brew link openssl --force

它会起作用。 :)

答案 3 :(得分:4)

试试这个

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

答案 4 :(得分:1)

如果上述答案对您没有帮助,您可以尝试将Ruby版本降级为2.1.2。这对我来说很有用(OS 10.10.2)。在Gemfile的顶部添加:

ruby '2.1.2'

答案 5 :(得分:0)

我记得安装另一个需要eventmachine的gem,它给了我windows中的问题。我必须安装DevKit工具,这解决了我的问题。对不起,我无法提供更多详细信息,但我希望它有助于解决您的问题。你也可以试试普拉卡什分享的above。安装Devkit后我最终必须更新自己。

答案 6 :(得分:0)

我知道很久以前就已经问过这个问题,但是我刚刚看到这个错误,在尝试了所有的答案并努力解决这个和另外几个宝石后我才意识到我正在尝试安装一个非常古老的项目,因此一些宝石与当前的库不兼容,其中大多数实际上是对实际项目宝石的要求。

我所做的就是删除Gemfile.lock文件,然后让bundler使用更多当前参考资料重新创建它,这对于我的案例非常有用,因此我会为其他人做出贡献最终得到同样的情况:

rm Gemfile.lock
bundle install

希望有所帮助!