colin
colin

Reputation: 557

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

Upvotes: 41

Views: 27737

Answers (7)

Stephane Paquet
Stephane Paquet

Reputation: 2344

What worked for me on Apple Silicon M1 and Rails 6.1

  • Full uninstall of eventmachine: gem uninstall -aIx eventmachine followed by a rm -rf vendor/cache
  • Add eventmachine in the project Gemfile and forcing it to be from the master branch latest like this gem 'eventmachine', :git => 'git://github.com/eventmachine/eventmachine.git', :branch => 'master'
  • Run bundle install

Upvotes: 3

Simon E.
Simon E.

Reputation: 58500

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.

Upvotes: 36

GorvGoyl
GorvGoyl

Reputation: 49290

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

Upvotes: 21

Emjey
Emjey

Reputation: 2063

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.

Upvotes: 33

grain miller
grain miller

Reputation: 9

gem install eventmachine --platform ruby

Upvotes: 0

colin
colin

Reputation: 557

The problem has fixed.

rm vendor/cache/ -rf
bundle install

fixed the error

remove the Redundant folder in the redmine/plugins

fixed the warnings

This is record of locating and repairing process.

thx all!

Upvotes: 1

Prakash Murthy
Prakash Murthy

Reputation: 13067

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.

Upvotes: 7

Related Questions