Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to load the EventMachine C extension; To use the pure-ruby reactor

i got trouble, in a rails project(redmine2.3), rails version is 3.2

start the project

bundle exec thin start -p 8080 -e production -s 5 -d

error info

(eval):9: warning: already initialized constant Bundler::Dsl::RAILS_VERSION_IS_3
(eval):9: warning: previous definition of RAILS_VERSION_IS_3 was here
(eval):9: warning: already initialized constant Bundler::Dsl::RAILS_VERSION_IS_3
(eval):9: warning: previous definition of RAILS_VERSION_IS_3 was here
Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby'
/var/wtn/vendor/cache/ruby/2.0.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:8:in `require': libruby.so.2.0: cannot open shared object file: No such file or directory - /var/wtn/vendor/cache/ruby/2.0.0/gems/eventmachine-1.0.3/lib/rubyeventmachine.so (LoadError)
    from /var/wtn/vendor/cache/ruby/2.0.0/gems/eventmachine-1.0.3/lib/eventmachine.rb:8:in `<top (required)>'
    from /var/wtn/vendor/cache/ruby/2.0.0/gems/thin-1.6.2/lib/thin.rb:7:in `require'
    from /var/wtn/vendor/cache/ruby/2.0.0/gems/thin-1.6.2/lib/thin.rb:7:in `<top (required)>'
    from /var/wtn/vendor/cache/ruby/2.0.0/gems/thin-1.6.2/bin/thin:5:in `require'
    from /var/wtn/vendor/cache/ruby/2.0.0/gems/thin-1.6.2/bin/thin:5:in `<top (required)>'
    from /var/wtn/vendor/cache/ruby/2.0.0/bin/thin:23:in `load'
    from /var/wtn/vendor/cache/ruby/2.0.0/bin/thin:23:in `<main>'

the same error happens when running rails -v

rails -v
(eval):9: warning: already initialized constant Bundler::Dsl::RAILS_VERSION_IS_3
(eval):9: warning: previous definition of RAILS_VERSION_IS_3 was here

running bundle exec ..... in the project produces the same error

the problem has solved, see my comment in the third floor , there are the answer

like image 371
colin Avatar asked Jun 06 '15 11:06

colin


4 Answers

If you are using windows

  1. Go to this folder C:\Ruby24-x64\lib\ruby\gems\2.4.0\gems\eventmachine-1.2.5-x64-mingw32\lib

  2. open this file eventmachine.rb

  3. write this require 'em/pure_ruby' in the first line of code in the file

this will make it work with no issues.

like image 126
Emjey Avatar answered Oct 22 '22 14:10

Emjey


I was encountering this error message on Windows 10 while trying to use Jekyll's LiveReload feature. The other answers here did not solve the problem completely, or risked having the issue re-occur the next time bundle install is run.

My solution (taken from this site) was to:

  1. Run this console command

    gem uninstall eventmachine 
    

    and choose to uninstall eventmachine-1.2.7-x64-mingw32 gems from your system.

  2. Edit Gemfile inside your project directory and add this line inside:

    gem 'eventmachine', '1.2.7', git: 'https://github.com/eventmachine/eventmachine.git', tag: 'v1.2.7'
    
  3. Run

    bundle install
    
  4. Clean up your jekyll build and cache with command

    bundle exec jekyll clean
    

You can now use the --livereload parameter without getting any issue, even if you execute bundle install in future.

like image 43
Simon East Avatar answered Oct 22 '22 12:10

Simon East


For Ruby 2.4 & eventmachine 1.2.6 on Windows 10.

You gotta uninstall first eventmachine and then install it again with platform ruby:

gem uninstall eventmachine  (select all versions if prompted)

gem install eventmachine --platform ruby
like image 21
GorvGoyl Avatar answered Oct 22 '22 13:10

GorvGoyl


The relevant error message here is the following:

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

Try to reinstall the eventmachine gem:

gem uninstall eventmachine
bundle install

See Rails/Ruby Error When Creating Database: Unable to load the EventMachine C extension and Rails - cannot run app: Unable to load the EventMachine C extension; for more advice on how to deal with this issue.

like image 8
Prakash Murthy Avatar answered Oct 22 '22 14:10

Prakash Murthy