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

colin
  • 557
  • 1
  • 4
  • 7
  • possible duplicate of [Rails - cannot run app: Unable to load the EventMachine C extension;](http://stackoverflow.com/questions/14824235/rails-cannot-run-app-unable-to-load-the-eventmachine-c-extension) – jvnill Jun 06 '15 at 13:46
  • not the same, see my comment in the third floor , there are the answer – colin Jun 06 '15 at 16:30

7 Answers7

35

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.

JEdwards
  • 34
  • 4
Simon East
  • 55,742
  • 17
  • 139
  • 133
  • 1
    Thanks @Simon East – Vidya Ganesh Aug 11 '21 at 22:30
  • 2
    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. – Even Wonder Oct 14 '21 at 14:02
  • @EvenWonder Hey did you just add the code on the first line of the gem file? bundle exec jekyll clean didn't work for me – Sarah V.P Jan 01 '22 at 07:41
  • 1
    @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. – Even Wonder Jan 02 '22 at 06:51
  • And if this doesn't work, https://stackoverflow.com/a/73913233/259453 might help – volvox Mar 13 '23 at 16:13
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.

Emjey
  • 2,038
  • 3
  • 18
  • 33
  • Save my life, uninstall and install do not work for me! – Denny Apr 24 '21 at 13:20
  • 3
    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\lib` – phougatv Jul 15 '21 at 05:06
  • I also have this issue – Evan Sep 28 '21 at 22:12
  • I'm with the same issue here – Odravison Nov 01 '21 at 00:43
  • worked with ruby-3.0.1 and eventmachine-1.2.7 on macos – F.E.A Dec 21 '21 at 12:12
  • 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 descriptor – CountDOOKU Jan 01 '22 at 05:49
  • For MacOS: /Library/Ruby/Gems/2.6.0/gems/eventmachine-1.2.7/lib/rubyeventmachine.b – Maxim Firsoff Apr 08 '22 at 03:39
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
GorvGoyl
  • 42,508
  • 29
  • 229
  • 225
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.

Community
  • 1
  • 1
Prakash Murthy
  • 12,923
  • 3
  • 46
  • 74
  • 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 here – colin Jun 06 '15 at 12:45
  • 1
    gem uninstall eventmachine seems got no tips back – colin Jun 06 '15 at 13:38
  • I also tried this but received the exact same error message. – Luke Jun 26 '18 at 03:24
  • 1
    I am getting this error `ERROR: While executing gem ... (Gem::DependencyRemovalException) Uninstallation aborted due to dependent gem(s) ` – Yashu Mittal Oct 12 '18 at 11:44
  • @YashuMittal See https://stackoverflow.com/questions/952836/do-i-have-to-manually-uninstall-all-dependent-gems for some tips on how to move past this error. – Prakash Murthy Oct 12 '18 at 17:59
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
Stephane Paquet
  • 2,315
  • 27
  • 31
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!

colin
  • 557
  • 1
  • 4
  • 7
0

gem install eventmachine --platform ruby