28

Here is the full output of the error message:

    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

Has anyone seen an error like this before? I have the command line tools - never ran into an error compiling this gem on my old laptop also running Yosemite.

Joel
  • 4,503
  • 1
  • 27
  • 41
tgmerritt
  • 714
  • 1
  • 7
  • 16

8 Answers8

47

EventMachine 1.0.3 didn’t work with Ruby 2.2. This was fixed in EventMachine 1.0.4. You can most likely fix your situation by upgrading EventMachine with

bundle update eventmachine
Rory O'Kane
  • 29,210
  • 11
  • 96
  • 131
tantrix
  • 1,248
  • 12
  • 14
46

For El Captain, this worked for me:

$ bundle update eventmachine # updated to v1.0.8
$ bundle config build.eventmachine --with-cppflags=-I/usr/local/opt/openssl/include
$ bundle install
Subhash Chandran
  • 1,275
  • 1
  • 13
  • 20
16

if you have brew install, try

brew install openssl

and if it still says,

Warning: openssl-1.0.2e already installed

then run this command ,

brew link openssl --force

it will do the trick. :)

kushvarma
  • 369
  • 2
  • 6
  • This works for me on a fresh install of El Capitan running Ruby 2.1.6. – arimbun Jan 28 '16 at 13:00
  • If you don't have the ability to update the ruby app's dependencies, this is a great answer. – RobW Feb 08 '16 at 16:35
  • downvoting because while this _does_ solve the issue, doing `brew link --force` isn't a terribly great idea. – strugee May 24 '16 at 19:14
  • @strugee i think you should google a little bit before commenting or downvoting. there is a limitation with openssl with OS X, that is why we need to forcefully link, Also you can also see on this link https://github.com/facebook/redex, even FB used --force for openssl. Dare to question them why they did it? Stackoverflow is community to help each other, not criticize, if you are criticizing you should be cent percent sure, why you are doing. thanks for downvoting. – kushvarma Jun 09 '16 at 11:00
  • It doesn't solve the problem for me. OSX El Capitan, eventmachine 1.0.3. – JoannaFalkowska Jun 23 '16 at 07:24
8

Try this

gem install eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include
AMP
  • 91
  • 1
  • 3
1

In case the above answer doesn't help you, you can try downgrading your Ruby version to 2.1.2. That did the trick for me (OS 10.10.2). Add this at the top of your Gemfile:

ruby '2.1.2'
maxhm10
  • 1,034
  • 9
  • 20
0

I remember installing another gem that required eventmachine and it gave me problems in windows. I had to install DevKit tools and that resolved my issue. sorry i cannot provide more details but I hope it helps to solve your issue. you can also try what Prakash shared above. I had to update myself in the end after installing Devkit.

Omar Sar
  • 138
  • 1
  • 8
  • This question is about OS X, since DevKit is specifically for Windows, this answer is unlikely to help those of us trying to build eventmachine on Macs. – Jeremy Weathers Oct 24 '15 at 15:58
0

I understand this question has been asked quite a while ago but I've seen this error just now and after trying all answers and struggling with this and another couple of gems I've realized that as I was trying to install a pretty old project and therefore some gems were not compatible with current libs and most of them were actually requirements for the actual project gems.

What I did then was remove the Gemfile.lock file and let bundler recreate it with more current references for the dependency gems and that worked for my case and therefore I'm contributing to others that eventually get on the same situation:

rm Gemfile.lock
bundle install

Hope that helps!

fagiani
  • 2,293
  • 2
  • 24
  • 31
0

First set the path of the brew openssl executable in your shell. (zshrc or bashrc). Source your shell.

Then do

 which openssl

Get the output and use it in your gem install dir path.

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

This worked for me.