32

I am not able to install eventmachine

Ok I know this has been asked quite a lot, but no solutions I found has helped me so far.So I posted here as a last resort.

I use windows 8 x64 using ruby 2.0.0p195 (x64) (installed throught Ruby Installer for Windows with the apropriate Devkit)

So the Error is

    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      

Things I have tried putting gem "eventmachine", "~> 1.0.3" or gem "eventmachine", "~> 1.0.0.beta.4.1" in my gemfile and removed/modify eventmachine from gemfile.lock making a new testapp and instaling Eventmachine there (fail)

Things I suspect I tracked down dependencies for eventmachine(can be found on Rubygems) and I see that I cannot install bluecloth neither (shows even bigger log error) and neither can I install tidy-ext (bluecloth depencency) so I think it might have some relevance , also cannot install thin

For any info just ask

Thank you all in advance!!

Vasspilka
  • 1,135
  • 1
  • 10
  • 22
  • 1
    It looks like a reported issue on github. The best I could find is to try and clone the latest eventmachine from github and build with that: https://groups.google.com/forum/#!topic/rubyinstaller/uCHtdKuuOPY/discussion – Casper Jun 28 '13 at 10:32
  • even newer versions like `Ruby 2.0.0-p247 (x64)` are affected by this problem – Mobiletainment Jul 19 '13 at 14:12

9 Answers9

61

I could install it, doing this steps:

1) tried a normal install:

gem install eventmachine

it fetched the version 1.0.3 of the gem, but failed in the make, because of a variable declaration conflit

2) edited the file:

c:\Ruby200-x64\lib\ruby\gems\2.0.0\gems\eventmachine-1.0.3\ext\project.h

and commented the line 97

//typedef int pid_t;

for a more robust correction, checkout the solution here https://github.com/eventmachine/eventmachine/pull/450/files

3) then, i've opened command prompt, and went to the gem folder

c:\Ruby200-x64\lib\ruby\gems\2.0.0\gems\eventmachine-1.0.3

and run:

gem build eventmachine.gemspec

You need git installed with the git.exe location in the PATH for this to work (such as C:\Users\YourUsername\AppData\Local\GitHub\PORTAB~1\bin).

4) it generated a eventmachine.gem file on the folder... So I've copied a file to a c:\tmp folder, and went to that folder and from there, I've typed:

gem install eventmachine-1.0.3.gem --local

And it installed successfully!

Junior Mayhé
  • 16,144
  • 26
  • 115
  • 161
Fernando Vieira
  • 3,177
  • 29
  • 26
  • 2
    I've been using Ubuntu since Windows started to freak me out :P, when I log into Windows I'll be sure to try that :) – Vasspilka Jul 02 '13 at 14:51
  • 6
    it works! But could it be that this causes problems with the eventmachine afterwards, like this error? `..'require': cannot load such file -- eventmachine (LoadError)` – Mobiletainment Jul 19 '13 at 14:37
  • Confirmed solution for me, much appreciated. I'll be sure to update you on if I see any errors like @Mobiletainment did. – signus Feb 14 '14 at 18:45
  • 2
    Yep - got the same error as the above. `C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/thin-1.6.1/lib/thin.rb:7:in 'require': cannot load such file -- eventmachine (LoadError)` – signus Feb 14 '14 at 19:20
  • @Mobiletainment Were you able to resolve this issue? – hypno7oad Mar 05 '14 at 21:51
  • @hypno7oad so the solution with generating the eventmachine.gemspec worked in the first place, but I ran from one problem into another afterwards. Eventually I solved it somehow, but I wasn't sure what exactly fixed it and unfortunately, I already forgot the solution by now. I'm sorry I wasn't attentive enough, I should have come back to this topic sooner .. I'm sorry for that! – Mobiletainment Mar 06 '14 at 14:43
  • @Mobiletainment Np and thanks for the reply. For some reason the solution above wasn't working for me (I couldn't require the file after altering and loading it locally). However, in the end I solved the issue by reverting from the Ruby 2.0.0 msi for Windows x64 down to the x86 msi. – hypno7oad Mar 06 '14 at 15:34
  • Of course it is needed to install devkit and github and add their bin paths into Windows environment variables. – Junior Mayhé Mar 25 '14 at 15:55
  • The eventmachine.gemspec get a list of all required files to pack on a *.gem file using the command 'git ls-files', which will list all working tree files of the repository. Because the folder don't have a git repository, the command output is blank and the local gem file is generated without any files(lib/) inside. Check out the file size of eventmachine-1.0.3.gem with no git repository, as we did following the solution above, and check out again, but this time before you exec command 'gem build ...', create a repository and add the files to the git's index. – Henrique Sobral Gomes Jul 28 '14 at 14:54
  • 1
    The fix has been merged into the eventmachine master branch. Grab the gem from the git repo like so `gem 'eventmachine', '1.0.3', :git => "git://github.com/eventmachine/eventmachine.git"`..this worked for me – Akshay Takkar Oct 02 '14 at 07:38
  • Have the same problem as @Mobiletainment and Signus - LoadError. Have you found a solutions guys? – Ján Janočko Nov 12 '15 at 11:31
  • @JánJanočko You need to have git installed. – Oliver Ni Sep 14 '16 at 04:00
37

This worked for me:

brew link openssl --force 
Undo
  • 25,519
  • 37
  • 106
  • 129
Kai
  • 371
  • 3
  • 4
  • This works for me because I have this error `Installing eventmachine 0.12.10 with native extensions Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb checking for rb_trap_immediate in ruby.h,rubysig.h... no checking for sys/queue.h... yes creating Makefile make "DESTDIR=" compiling binder.cpp In file included from binder.cpp:20: ./project.h:103:10: fatal error: 'openssl/ssl.h' file not found #include ^ 1 error generated. make: *** [binder.o] Error 1` – Helder Robalo Nov 12 '15 at 10:26
  • This worked for me like a charm, so here's my one vote! – Askar Dec 07 '15 at 10:59
  • This doesn't work in 2k18. Use that answer - https://stackoverflow.com/a/42619738/1514072 – Евгений Масленков Jan 15 '18 at 19:16
19

Try

gem install eventmachine -- --with-cppflags=-I/usr/local/opt/openssl/include
Rajat Bansal
  • 885
  • 9
  • 7
11

I got an error as below


C:\Ruby200-x64\lib\ruby\gems\2.0.0\gems\eventmachine-1.0.3>gem build eventmachine.gemspec Invalid gemspec in [eventmachine.gemspec]: No such file or directory - git ls-files

ERROR: Error loading gemspec. Aborting.

However, I kept the project.h opened in textpad and tried to do gem install eventmachine. At one point, textpad will ask a confirmation to reload project.h as the new file is fetched from gem install command.. just give reload and comment the line //typedef int pid_t;.. Then the compilation went through..

basically, it takes a while to start the compilation after fetching the gem project files. Just use that time to comment htis line.. It worked for me.. may not work for everyone.

Cheers!

chank
  • 3,546
  • 1
  • 14
  • 22
  • haha, very smart. just make sure you comment out `typedef int pid_t;` and save the file as fast as you can. Get it done before the compiler read the file. – Ricky May 05 '14 at 07:31
  • Very nice, I used Notepad++ and when it asked if I wanted to reload I said no then hit ctrl+s to save the version of the file in the editor, as I already had line 97 commented out, and it worked. – Travis Pessetto May 19 '14 at 19:14
6

I had the same problem and successfully able to run it by adding below at the beginning of the Gemfile:

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

Before that I uninstalled eventmachine.

Jama A.
  • 15,680
  • 10
  • 55
  • 88
  • 1
    This worked for me. I added the event machine gem line to the start (I was trying to install barkeep) – Ian1971 Dec 19 '14 at 17:12
  • 1
    This worked great for me as well within the context of Heroku's new Docker setup. Event machine was failing, added to the top, and my container was able to start. Thanks! – cnp May 11 '15 at 04:27
  • 1
    Works for me too. Rails 6.1 on Apple Silicon M1. – Stephane Paquet Dec 19 '21 at 21:45
2

I faced similar issues today for eventmachine gem (for both version 1.0.3 & 1.0.4) while upgrading to Ruby 2.2.0. And I fixed it by installing latest "developer tools" for MAC OSX 10.10.1 Yosemite and XCode 6.1.1

Here is my detailed blog post for resolving this issue with eventmachine gem installation - https://blog.kiprosh.com/upgrading-to-ruby-2-2-0-issues-installing-gem-eventmachine/

Rohan Daxini
  • 496
  • 4
  • 12
2

I had the same problem in linux.

I solved it by upgrading ruby to ruby-2.2.1.

Neha Suwal
  • 371
  • 1
  • 7
0

The above answer on how to compile did not work for me, as I would get the "cannot load such file" message. I resolved this problem by running the gem build eventmachine.gemspec from a git checkout of the eventmachine repo.

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

You should be able to see that the size of the .gem file is much greater as it actually includes the proper code.

sparkym3
  • 12,467
  • 2
  • 12
  • 3
0

You can try this answer here: Rails - cannot run app: Unable to load the EventMachine C extension;

The Accepted answer to this question works. But you'll have other problems as shown in the comments below.

Follow the solution by suda in the link, you'll be fine.

(Actually, it's basically compiling and installing gem from the master github code repo. I was surprised they haven't pushed the issue fix into master yet, since they're aware of it.)

Community
  • 1
  • 1
Rui Liu
  • 376
  • 4
  • 9