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

7

41

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

Placeeda answered 6/6, 2015 at 11:58 Comment(2)
possible duplicate of Rails - cannot run app: Unable to load the EventMachine C extension;Mi
not the same, see my comment in the third floor , there are the answerPlaceeda
T
36

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.

Tenebrific answered 3/1, 2021 at 5:47 Comment(6)
Thanks @Simon EastMum
Thanks, I'm also encountering this error message on Windows 10 while trying to use Jekyll's LiveReload feature and it works for me as well.Glasscock
@EvenWonder Hey did you just add the code on the first line of the gem file? bundle exec jekyll clean didn't work for meRosebay
@SarahV.P Hey, have you found out the solution? I think the last line is more appropriate. Besides, bundle exec jekyll clean is just to clean some auto generated files, there is no relationship between them.Glasscock
And if this doesn't work, https://mcmap.net/q/392499/-i-can-39-t-install-eventmachine-gem-on-mac-m1 might helpAlphard
This solved my issue, love yaCongruous
S
33

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.

Stonefly answered 31/10, 2018 at 9:27 Comment(7)
Save my life, uninstall and install do not work for me!Outmaneuver
It gave me the following error - The ``SortedSet`` class has been extracted from the ``set`` library.You must use the ``sorted_set`` gem or other alternatives. (RuntimeError). On my machine the path to the file you specified is - C:\Ruby30-x64\lib\ruby\gems\3.0.0\gems\eventmachine-1.2.7-x64-mingw32\libSerilda
I also have this issueNabob
I'm with the same issue hereResurge
worked with ruby-3.0.1 and eventmachine-1.2.7 on macosLandscapist
it worked for a while, I received a subsequent error C:/Ruby27-x64/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7-x64-mingw32/lib/em/pure_ruby.rb:559:in `close': Bad file descriptorGolly
For MacOS: /Library/Ruby/Gems/2.6.0/gems/eventmachine-1.2.7/lib/rubyeventmachine.bDiphenylhydantoin
M
21

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
Mignonne answered 3/11, 2019 at 19:32 Comment(1)
Doesn't work for MacOS for eventmachine 1.2.7Alphard
K
7

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.

Keratogenous answered 6/6, 2015 at 12:44 Comment(5)
what about the warning: (eval):9: warning: already initialized constant Bundler::Dsl::RAILS_VERSION_IS_3 (eval):9: warning: previous definition of RAILS_VERSION_IS_3 was herePlaceeda
gem uninstall eventmachine seems got no tips backPlaceeda
I also tried this but received the exact same error message.Aldon
I am getting this error ERROR: While executing gem ... (Gem::DependencyRemovalException) Uninstallation aborted due to dependent gem(s) Marmara
@YashuMittal See #953336 for some tips on how to move past this error.Keratogenous
F
3

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
Fencesitter answered 19/12, 2021 at 21:48 Comment(0)
P
1

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!

Placeeda answered 6/6, 2015 at 16:14 Comment(0)
B
0

gem install eventmachine --platform ruby

Bowls answered 10/4, 2018 at 20:20 Comment(2)
Try to explain at least a little?Agriculture
Before uninstall eventmachine with gem uninstall eventmachine: github.com/oneclick/rubyinstaller2/issues/…Moleskin

© 2022 - 2024 — McMap. All rights reserved.