ruby 在OSX约塞米蒂上安装EventMachine gem时出错

eqzww0vc  于 2023-04-20  发布在  Ruby
关注(0)|答案(8)|浏览(135)

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

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

以前有没有人见过这样的错误?我有命令行工具-在我的旧笔记本电脑上编译这个gem时从来没有遇到过错误,我也运行约塞米蒂。

9vw9lbht

9vw9lbht1#

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

bundle update eventmachine
wydwbb8l

wydwbb8l2#

对于队长来说,这对我很有效:

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

webghufk3#

如果已安装brew,请尝试

brew install openssl

如果上面还写着

Warning: openssl-1.0.2e already installed

然后运行此命令,

brew link openssl --force

它会起作用的。:)

6xfqseft

6xfqseft4#

试试这个

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

f0brbegy5#

如果上面的答案对你没有帮助,你可以试着把你的Ruby版本降级到2.1.2。这对我来说很有用(OS 10.10.2)。在你的Gemfile顶部添加以下内容:

ruby '2.1.2'
r7knjye2

r7knjye26#

我记得安装了另一个需要eventmachine的gem,它给了我在windows中的问题。我不得不安装DevKit工具,解决了我的问题。对不起,我不能提供更多的细节,但我希望它有助于解决你的问题。你也可以尝试Prakash分享的above。我不得不在安装Devkit后更新自己。

nwlls2ji

nwlls2ji7#

我知道这个问题已经问了很久了,但我刚才看到了这个错误,在尝试了所有答案并与此和另一对夫妇的gems斗争后,我意识到,因为我试图安装一个相当旧的项目,因此一些gems与当前的libs不兼容,其中大部分实际上是实际项目gems的要求。
然后我删除了Gemfile.lock文件,让bundler用更多的依赖项gem的当前引用重新创建它,这对我的案例很有效,因此我为最终遇到同样情况的其他人做出了贡献:

rm Gemfile.lock
bundle install

希望有帮助!

mrzz3bfm

mrzz3bfm8#

首先在你的shell中设置brew openssl可执行文件的路径。(zshrc或bashrc)。
那就做吧

which openssl

获取输出并在gem安装目录路径中使用它。

gem install eventmachine  -v '1.2.7' -- --with-openssl-dir=/usr/local/opt/openssl@1.1/bin/openssl

这对我很有效。

相关问题