【问题标题】:Error installing EventMachine gem on OSX Yosemite在 OSX Yosemite 上安装 EventMachine gem 时出错
【发布时间】:2017-02-11 08:38:52
【问题描述】:

这是错误消息的完整输出:

    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

以前有人见过这样的错误吗?我有命令行工具 - 在我也运行 Yosemite 的旧笔记本电脑上编译此 gem 时从未遇到过错误。

【问题讨论】:

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


【解决方案1】:

EventMachine 1.0.3 didn’t work with Ruby 2.2。这已在 EventMachine 1.0.4 中修复。您最有可能通过升级 EventMachine 来解决您的问题

bundle update eventmachine

【讨论】:

  • 为我工作。谢谢!
【解决方案2】:

对于 El Captain,这对我有用:

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

【讨论】:

  • 这就是解决方案!
  • 我收到An error occurred while installing eventmachine (1.0.8), and Bundler cannot continue.
  • 第二行对我有用。我在使用全新的应用程序时遇到了问题(其中捆绑更新事件机器没有意义)。
  • 这里也一样---第二行对我有用。 OSX El Capitan 运行 Ruby 2.3.0。
  • 这是解决方案!...更改为 ruby​​ 2.2.2 并捆绑在 El Capitan 上。谢谢
【解决方案3】:

如果你有 brew 安装,试试

brew install openssl

如果它仍然说,

Warning: openssl-1.0.2e already installed

然后运行这个命令,

brew link openssl --force

它会成功的。 :)

【讨论】:

  • 这适用于我全新安装运行 Ruby 2.1.6 的 El Capitan。
  • 如果您没有能力更新 ruby​​ 应用程序的依赖项,这是一个很好的答案。
  • 投反对票,因为虽然这确实解决了问题,但 brew link --force 并不是一个非常好的主意。
  • @strugee 我认为您应该在评论或投票之前先用谷歌搜索一下。 OS X 的 openssl 存在限制,这就是我们需要强制链接的原因,您也可以在此链接上看到 github.com/facebook/redex,甚至 FB 使用 --force 来表示 openssl。敢于质疑他们为什么这样做? * 是一个互相帮助的社区,而不是批评,如果你批评你应该百分之百确定你为什么这样做。感谢您的投票。
  • 它不能解决我的问题。 OSX El Capitan,事件机器 1.0.3。
【解决方案4】:

试试这个

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

【讨论】:

    【解决方案5】:

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

    ruby '2.1.2'
    

    【讨论】:

    • 我有 ruby '2.2.2' 但这没有帮助。
    【解决方案6】:

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

    【讨论】:

    • 这个问题是关于 OS X 的,因为 DevKit 是专门用于 Windows 的,所以这个答案不太可能帮助我们这些试图在 Mac 上构建 eventmachine 的人。
    【解决方案7】:

    我知道很久以前就有人问过这个问题,但我刚刚看到了这个错误,在尝试了所有答案并与这个和另外几个 gem 苦苦挣扎之后,我意识到当我试图安装一个漂亮的旧项目,因此一些 gem 与当前库不兼容,其中大多数实际上是实际项目 gem 的要求。

    然后我所做的是删除 Gemfile.lock 文件并让 bundler 重新创建它,并使用更多当前对依赖项 gem 的引用,这适用于我的情况,因此我正在为最终遇到相同情况的其他人做出贡献:

    rm Gemfile.lock
    bundle install
    

    希望有帮助!

    【讨论】: