Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to load the EventMachine C extension, ruby 2.7.4, Mac OS 12.0.1 x86 #960

Open
zololucky opened this issue Nov 19, 2021 · 17 comments
Open

Comments

@zololucky
Copy link

zololucky commented Nov 19, 2021

Hello, This is what I get when I run the rails s command:

Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby'
Traceback (most recent call last):
	35: from bin/rails:3:in `<main>'
	34: from bin/rails:3:in `load'
	33: from /Users/zolo.y/GitHub/Microsites/site_generator/bin/spring:15:in `<top (required)>'
	32: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
	31: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:83:in `require'
	30: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `<top (required)>'
	29: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/binstub.rb:11:in `load'
	28: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/spring-2.1.1/bin/spring:49:in `<top (required)>'
	27: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/client.rb:30:in `run'
	26: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/client/command.rb:7:in `call'
	25: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `call'
	24: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/spring-2.1.1/lib/spring/client/rails.rb:28:in `load'
	23: from /Users/zolo.y/GitHub/Microsites/site_generator/bin/rails:9:in `<top (required)>'
	22: from /Users/zolo.y/GitHub/Microsites/site_generator/bin/rails:9:in `require'
	21: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/railties-5.1.7/lib/rails/commands.rb:16:in `<top (required)>'
	20: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/railties-5.1.7/lib/rails/command.rb:44:in `invoke'
	19: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/railties-5.1.7/lib/rails/command/base.rb:63:in `perform'
	18: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor.rb:392:in `dispatch'
	17: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/invocation.rb:127:in `invoke_command'
	16: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/thor-1.1.0/lib/thor/command.rb:27:in `run'
	15: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/railties-5.1.7/lib/rails/commands/server/server_command.rb:130:in `perform'
	14: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/railties-5.1.7/lib/rails/commands/server/server_command.rb:130:in `tap'
	13: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/railties-5.1.7/lib/rails/commands/server/server_command.rb:133:in `block in perform'
	12: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/railties-5.1.7/lib/rails/commands/server/server_command.rb:133:in `require'
	11: from /Users/zolo.y/GitHub/Microsites/site_generator/config/application.rb:7:in `<top (required)>'
	10: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/2.7.0/bundler.rb:174:in `require'
	 9: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/2.7.0/bundler/runtime.rb:58:in `require'
	 8: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/2.7.0/bundler/runtime.rb:58:in `each'
	 7: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/2.7.0/bundler/runtime.rb:69:in `block in require'
	 6: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/2.7.0/bundler/runtime.rb:69:in `each'
	 5: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/2.7.0/bundler/runtime.rb:74:in `block (2 levels) in require'
	 4: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/2.7.0/bundler/runtime.rb:74:in `require'
	 3: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/thin-1.8.1/lib/thin.rb:7:in `<top (required)>'
	 2: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/thin-1.8.1/lib/thin.rb:7:in `require'
	 1: from /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:8:in `<top (required)>'
/Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:8:in `require': dlopen(/Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7/lib/rubyeventmachine.bundle, 0x0009): symbol not found in flat namespace '_ERR_load_crypto_strings' - /Users/zolo.y/.rbenv/versions/2.7.4/lib/ruby/gems/2.7.0/gems/eventmachine-1.2.7/lib/rubyeventmachine.bundle (LoadError)
  • ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-darwin21]
  • Rails 5.1.7
  • eventmachine-1.2.7

Thank you.

@sheuer
Copy link

sheuer commented Dec 30, 2021

I'm also running into this issue on an M1 Mac running Mac OS 12.1 trying to run a sinatra app /w rainbows.

  • ruby 2.5.1p57 (2018-03-29 revision 63029) [-darwin21]
  • eventmachine-1.2.7
Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby'
Traceback (most recent call last):
	22: from /Users/<>/.rvm/gems/ruby-2.5.1@push/bin/ruby_executable_hooks:22:in `<main>'
	21: from /Users/<>/.rvm/gems/ruby-2.5.1@push/bin/ruby_executable_hooks:22:in `eval'
	20: from /Users/<>/.rvm/gems/ruby-2.5.1@push/bin/rainbows:23:in `<main>'
	19: from /Users/<>/.rvm/gems/ruby-2.5.1@push/bin/rainbows:23:in `load'
	18: from /Users/<>/.rvm/gems/ruby-2.5.1@push/gems/rainbows-5.2.1/bin/rainbows:127:in `<top (required)>'
	17: from /Users/<>/.rvm/gems/ruby-2.5.1@push/gems/rainbows-5.2.1/bin/rainbows:127:in `new'
	16: from /Users/<>/.rvm/gems/ruby-2.5.1@push/gems/rainbows-5.2.1/lib/rainbows/http_server.rb:20:in `initialize'
	15: from /Users/<>/.rvm/gems/ruby-2.5.1@push/gems/unicorn-5.8.0/lib/unicorn/http_server.rb:79:in `initialize'
	14: from /Users/<>/.rvm/gems/ruby-2.5.1@push/gems/unicorn-5.8.0/lib/unicorn/http_server.rb:79:in `new'
	13: from /Users/<>/.rvm/gems/ruby-2.5.1@push/gems/unicorn-5.8.0/lib/unicorn/configurator.rb:78:in `initialize'
	12: from /Users/<>/.rvm/gems/ruby-2.5.1@push/gems/unicorn-5.8.0/lib/unicorn/configurator.rb:85:in `reload'
	11: from /Users/<>/.rvm/gems/ruby-2.5.1@push/gems/unicorn-5.8.0/lib/unicorn/configurator.rb:85:in `instance_eval'
	10: from rainbows.rb:1:in `reload'
	9: from /Users/<>/.rvm/gems/ruby-2.5.1@push/gems/rainbows-5.2.1/lib/rainbows/configurator.rb:48:in `Rainbows!'
	8: from /Users/<>/.rvm/gems/ruby-2.5.1@push/gems/rainbows-5.2.1/lib/rainbows/configurator.rb:48:in `instance_eval'
	7: from rainbows.rb:2:in `block in reload'
	6: from /Users/<>/.rvm/gems/ruby-2.5.1@push/gems/rainbows-5.2.1/lib/rainbows/configurator.rb:85:in `use'
	5: from /Users/<>/.rvm/gems/ruby-2.5.1@push/gems/rainbows-5.2.1/lib/rainbows/configurator.rb:85:in `const_get'
	4: from /Users/<>/.rvm/gems/ruby-2.5.1@push/gems/rainbows-5.2.1/lib/rainbows/configurator.rb:85:in `require'
	3: from /Users/<>/.rvm/gems/ruby-2.5.1@push/gems/rainbows-5.2.1/lib/rainbows/event_machine.rb:2:in `<top (required)>'
	2: from /Users/<>/.rvm/gems/ruby-2.5.1@push/gems/rainbows-5.2.1/lib/rainbows/event_machine.rb:2:in `require'
	1: from /Users/<>/.rvm/gems/ruby-2.5.1@push/gems/eventmachine-1.2.7/lib/eventmachine.rb:8:in `<top (required)>'
/Users/<>/.rvm/gems/ruby-2.5.1@push/gems/eventmachine-1.2.7/lib/eventmachine.rb:8:in `require': dlopen(/Users/<>/.rvm/gems/ruby-2.5.1@push/gems/eventmachine-1.2.7/lib/rubyeventmachine.bundle, 0x0009): symbol not found in flat namespace '_ERR_load_crypto_strings' - /Users/<>/.rvm/gems/ruby-2.5.1@push/gems/eventmachine-1.2.7/lib/rubyeventmachine.bundle (LoadError)

@themudassarhassan
Copy link

facing the same issue on mac m1. Any solution?

@Dovizu
Copy link

Dovizu commented Jan 9, 2022

Likewise

Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby'
                    ------------------------------------------------
      Jekyll 4.2.1   Please append `--trace` to the `serve` command 
                     for any additional information or backtrace. 
                    ------------------------------------------------
/Users/Donny/.rvm/gems/ruby-3.1.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:8:in `require': dlopen(/Users/Donny/.rvm/gems/ruby-3.1.0/gems/eventmachine-1.2.7/lib/rubyeventmachine.bundle, 0x0009): symbol not found in flat namespace '_SSL_get1_peer_certificate' - /Users/Donny/.rvm/gems/ruby-3.1.0/gems/eventmachine-1.2.7/lib/rubyeventmachine.bundle (LoadError)
	from /Users/Donny/.rvm/gems/ruby-3.1.0/gems/eventmachine-1.2.7/lib/eventmachine.rb:8:in `<top (required)>'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/gems/em-websocket-0.5.3/lib/em-websocket.rb:3:in `require'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/gems/em-websocket-0.5.3/lib/em-websocket.rb:3:in `<top (required)>'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/gems/jekyll-4.2.1/lib/jekyll/commands/serve/live_reload_reactor.rb:3:in `require'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/gems/jekyll-4.2.1/lib/jekyll/commands/serve/live_reload_reactor.rb:3:in `<top (required)>'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/gems/jekyll-4.2.1/lib/jekyll/commands/serve.rb:143:in `require_relative'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/gems/jekyll-4.2.1/lib/jekyll/commands/serve.rb:143:in `register_reload_hooks'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/gems/jekyll-4.2.1/lib/jekyll/commands/serve.rb:98:in `process'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/gems/jekyll-4.2.1/lib/jekyll/command.rb:91:in `block in process_with_graceful_fail'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/gems/jekyll-4.2.1/lib/jekyll/command.rb:91:in `each'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/gems/jekyll-4.2.1/lib/jekyll/command.rb:91:in `process_with_graceful_fail'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/gems/jekyll-4.2.1/lib/jekyll/commands/serve.rb:86:in `block (2 levels) in init_with_program'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `block in execute'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `each'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/gems/mercenary-0.4.0/lib/mercenary/command.rb:221:in `execute'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/gems/mercenary-0.4.0/lib/mercenary/program.rb:44:in `go'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/gems/mercenary-0.4.0/lib/mercenary.rb:21:in `program'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/gems/jekyll-4.2.1/exe/jekyll:15:in `<top (required)>'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/bin/jekyll:25:in `load'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/bin/jekyll:25:in `<main>'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/bin/ruby_executable_hooks:22:in `eval'
	from /Users/Donny/.rvm/gems/ruby-3.1.0/bin/ruby_executable_hooks:22:in `<main>'

@adampal
Copy link

adampal commented Jan 14, 2022

I was able to get it working by doing:

gem uninstall eventmachine

Then adding this to my gem file:

gem 'eventmachine', :git => 'git://github.com/eventmachine/eventmachine.git', :branch => 'master'

I'm guessing there's some updates currently in the master branch that have not been released as an update to the gem.

@sshock
Copy link

sshock commented Mar 3, 2022

If there have been important fixes, why has there been no new releases in almost 4 years?

@sshock
Copy link

sshock commented Mar 4, 2022

In my case I ended up here because I built eventmachine using the openssl at $(brew --prefix openssl), which happens to be /opt/homebrew/opt/openssl@3.

I redid it using openssl@1.1 and now I'm not running into this error anymore:

gem uninstall eventmachine
bundle config build.eventmachine --with-openssl-dir=$(brew --prefix openssl@1.1)
bundle

@adampal
Copy link

adampal commented Mar 8, 2022

If there have been important fixes, why has there been no new releases in almost 4 years?

@sshock good question.

Are @sodabrew @olleolleolle or any of the other recent contributors able to shed any light on the situation here? There have been a lot of commits to the main branch but no gem release since 2018.

@RoskiDeluge
Copy link

RoskiDeluge commented May 13, 2022

I'm having this issue and uninstalling/installing has not worked, neither did sshock solution above. I'm on a 2021 Mac M1 machine:
Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby'

dlopen(/Users/katana/MIJE/sandbox-mije-jekyll/vendor/bundle/ruby/3.1.0/bundler/gems/eventmachine-9cb13a8a6236/lib/rubyeventmachine.bundle, 0x0009): symbol not found in flat namespace '_SSL_get1_peer_certificate'

Ruby: ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [arm64-darwin21]


UPDATE: I was able to fix this by simply getting everything up-to-date:
gem update --system

Then ensured that I have openssl@3 and ruby-3.1.1 on the Mac and, finally, eventmachine 1.2.7 in my project's Gemfile.
Then bundle update and bundle exec jekyll serve

@TorvaldsDB
Copy link

TorvaldsDB commented Nov 30, 2022

In my case I ended up here because I built eventmachine using the openssl at $(brew --prefix openssl), which happens to be /opt/homebrew/opt/openssl@3.

I redid it using openssl@1.1 and now I'm not running into this error anymore:

gem uninstall eventmachine
bundle config build.eventmachine --with-openssl-dir=$(brew --prefix openssl@1.1)
bundle

this does not work for me.

I fix it by

gem install eventmachine -v '1.2.7' -- --with-ldflags="-Wl,-undefined,dynamic_lookup"

@cesarcoatl
Copy link

@TorvaldsDB's suggestion worked for me.

I fix it by

gem install eventmachine -v '1.2.7' -- --with-ldflags="-Wl,-undefined,dynamic_lookup"

Cheers!

@nywton
Copy link

nywton commented Dec 30, 2022

In my case I ended up here because I built eventmachine using the openssl at $(brew --prefix openssl), which happens to be /opt/homebrew/opt/openssl@3.
I redid it using openssl@1.1 and now I'm not running into this error anymore:

gem uninstall eventmachine
bundle config build.eventmachine --with-openssl-dir=$(brew --prefix openssl@1.1)
bundle

this does not work for me.

I fix it by

gem install eventmachine -v '1.2.7' -- --with-ldflags="-Wl,-undefined,dynamic_lookup"

Thanks! It worked for me

jessesquires added a commit to jessesquires/jessesquires.com that referenced this issue Jan 16, 2023
This is a forward-fix from 598a9fc.

NFSN is on Ruby 2.7.6, so we need to use that unfortunately. Will upgrade once NFSN upgrades.

Adds a `.ruby-version` file to simplify setup.

There were issues installing `eventmachine`, resolved by: eventmachine/eventmachine#960 (comment)

```
gem install eventmachine -v '1.2.7' -- --with-ldflags="-Wl,-undefined,dynamic_lookup"
```
@shushugah
Copy link

This worked for me, thank you!

@roryabraham
Copy link

roryabraham commented Aug 19, 2023

For me I had to do:

bundle config build.eventmachine --with-ldflags="-Wl,-undefined,dynamic_lookup"
bundle install

@dimitrovv
Copy link

Then adding this to my gem file:

gem 'eventmachine', :git => 'git://github.com/eventmachine/eventmachine.git', :branch => 'master'

This is the only fix that worked for me, tried everything else above with no luck. So, the below is fine but a new version has to be released here of the 💎 , the last one is 1.2.7 since 2018:

gem 'eventmachine', '= 1.3.0.dev.1', github: 'eventmachine', branch: 'master'

...

git_source(:github) { |repo_name| "https://github.com/#{repo_name}.git" }

@faizantroon
Copy link

Thanks, Thats work for me as well despite all other options

@hoangtaiki
Copy link

hoangtaiki commented Nov 2, 2023

I was able to get it working by doing:

bundle config build.eventmachine --with-pkg-config=$(brew --prefix openssl@1.1)/lib/pkgconfig
bundle install --redownload

@MSP-Greg
Copy link
Contributor

MSP-Greg commented Nov 2, 2023

I'm not that familiar with either EventMachine or macOS.

But, for those who've needed to set either --with-openssl-dir or --with-pkg-config, does the output of the following contain an OpenSSL directory? If so, EM might be able to be patched to fix the need for either of the arguments.

ruby -e "puts RbConfig::CONFIG['configure_args']"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests