Rails - cannot run app: Unable to load the EventMachine C extension;

前端 未结 5 1046
栀梦
栀梦 2020-12-06 20:27

When I run an app on Lion OS X, I get this error:

Unable to load the EventMachine C extension; To use the pure-ruby reactor, require \'em/pure_ruby\'
/Users/         


        
相关标签:
5条回答
  • 2020-12-06 20:57

    In my case this fixed it:

    • $ gem uninstall eventmachine
    • at the prompt tell it to uninstall all versions (it tells you about dependencies)
    • $ bundle install

    I was reading through this https://github.com/eventmachine/eventmachine/issues/333. There were problems with eventmachine, so making sure I got the newest version seemed a good idea.

    0 讨论(0)
  • 2020-12-06 21:11

    For me, compiling eventmachine from sources with tweaked config helped. Try:

    Uninstall eventmachine if it's already installed:

    gem uninstall eventmachine
    

    Fetch eventmachine sources:

    git clone https://github.com/eventmachine/eventmachine.git
    cd eventmachine
    

    Edit ext/extconf.rb and ext/fastfilereader/extconf.rb files by adding CONFIG['CXX'] = "g++" right after require 'mkmf'

    Compile and install gem:

    rake gem
    gem install pkg/eventmachine-1.0.3.gem
    

    Now eventmachine should work just fine :)

    0 讨论(0)
  • 2020-12-06 21:11

    The easiest fix as the message says is just to require 'em/pure_ruby'. I think you can put this in the config/inlitializers folder, you can call the file event_machine.rb

    But it won't have the same performance as the C extension.

    0 讨论(0)
  • 2020-12-06 21:12

    Providing another solution as I just wasted hours tracking this issue down. I was doing bundle install --deployment and then committing the result to a separate branch in git so I could deploy this branch straight to servers without having to do bundle install again.

    The problem is that eventmachine has a .gitignore file in it which tells git to ignore all *.so files. Because of this when I was committing, the .so files didn't commit, and wouldn't show up as untracked in a git status. Also since the gemspec was present, bundle thought the package was completely installed.

    My solution was to add a command as part of the build process to go and whack all the .gitignore files in the gems before committing.

    0 讨论(0)
  • 2020-12-06 21:12

    You may find various errors while installing gems or trying to find solution to your ruby application installation failing due to ruby-devel was not installed.

    I just installed on my Kali linux with

    sudo apt-get install ruby-dev

    and everything resolved. I was trying to install bettercap.

    This answer helped: https://stackoverflow.com/a/4502672/6503117

    0 讨论(0)
提交回复
热议问题