Error with eventmachine

Hi!

I used to be able to run jekyll on my MacOS. However, recently, I cannot do it anymore. Running bundle exec jekyll serve returns

bundler: command not found: jekyll
Install missing gem executables with `bundle install`

When I ran bundle install, I got errors about eventmachine as follows:

Bundler 2.5.16 is running, but your lockfile was generated with 2.4.15. Installing Bundler 2.4.15 and restarting using that version.
Fetching gem metadata from https://rubygems.org/.
Fetching bundler 2.4.15
Installing bundler 2.4.15
Fetching gem metadata from https://rubygems.org/...........
Resolving dependencies...
Resolving dependencies...
Using bundler 2.4.15
Using http_parser.rb 0.8.0
Fetching ffi 1.15.5
Fetching public_suffix 5.0.1
Fetching concurrent-ruby 1.2.2
Fetching google-protobuf 3.22.2
Using forwardable-extended 2.6.0
Using rb-fsevent 0.11.2
Fetching rexml 3.2.5
Using liquid 4.0.4
Using mercenary 0.4.0
Fetching rouge 4.1.0
Installing colorator 1.1.0
Using safe_yaml 1.0.5
Fetching unicode-display_width 2.4.2
Installing eventmachine 1.2.7 with native extensions
Installing public_suffix 5.0.1
Fetching webrick 1.8.1
Installing unicode-display_width 2.4.2
Fetching jekyll-paginate 1.1.0
Installing rouge 4.1.0
Installing ffi 1.15.5 with native extensions
Installing webrick 1.8.1
Installing rexml 3.2.5
Installing jekyll-paginate 1.1.0
Using pathutil 0.16.2
Fetching addressable 2.8.1
Using terminal-table 3.0.2
Installing google-protobuf 3.22.2 with native extensions
Fetching kramdown 2.4.0
Installing addressable 2.8.1
Installing concurrent-ruby 1.2.2
Installing kramdown 2.4.0
Fetching i18n 1.12.0
Installing i18n 1.12.0
Using kramdown-parser-gfm 1.1.0
Fetching sass-embedded 1.59.3 (arm64-darwin)
Fetching rb-inotify 0.10.1
Installing rb-inotify 0.10.1
Fetching listen 3.8.0
Installing sass-embedded 1.59.3 (arm64-darwin)
Installing listen 3.8.0
Using jekyll-watch 2.2.1
Using jekyll-sass-converter 3.0.0
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/khoi/.gem/ruby/3.3.5/gems/eventmachine-1.2.7/ext
/Users/khoi/.rubies/ruby-3.3.5/bin/ruby extconf.rb
checking for pkg-config for openssl... not found
checking for -lcrypto... yes
checking for -lssl... yes
checking for openssl/ssl.h... yes
checking for openssl/err.h... yes
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... no
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_fd_select()... yes
checking for rb_fdset_t in ruby/intern.h... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_enable_interrupt()... no
checking for rb_time_new()... yes
checking for inotify_init() in sys/inotify.h... no
checking for __NR_inotify_init in sys/syscall.h... no
checking for writev() in sys/uio.h... yes
checking for pipe2() in unistd.h... no
checking for accept4() in sys/socket.h... no
checking for SOCK_CLOEXEC in sys/socket.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for clock_gettime()... yes
checking for CLOCK_MONOTONIC_RAW in time.h... yes
checking for CLOCK_MONOTONIC in time.h... yes
CXXFLAGS=-fdeclspec
creating Makefile

current directory: /Users/khoi/.gem/ruby/3.3.5/gems/eventmachine-1.2.7/ext
make DESTDIR\= sitearchdir\=./.gem.20241118-62423-7ufrc1
sitelibdir\=./.gem.20241118-62423-7ufrc1 clean

current directory: /Users/khoi/.gem/ruby/3.3.5/gems/eventmachine-1.2.7/ext
make DESTDIR\= sitearchdir\=./.gem.20241118-62423-7ufrc1
sitelibdir\=./.gem.20241118-62423-7ufrc1
compiling binder.cpp
make: *** [binder.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/khoi/.gem/ruby/3.3.5/gems/eventmachine-1.2.7
for inspection.
Results logged to
/Users/khoi/.gem/ruby/3.3.5/extensions/arm64-darwin-24/3.3.0-static/eventmachine-1.2.7/gem_make.out

  /Users/khoi/.rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/ext/builder.rb:125:in `run'
/Users/khoi/.rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/ext/builder.rb:51:in `block
in make'
  /Users/khoi/.rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/ext/builder.rb:43:in `each'
  /Users/khoi/.rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/ext/builder.rb:43:in `make'
/Users/khoi/.rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/ext/ext_conf_builder.rb:42:in
`build'
/Users/khoi/.rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/ext/builder.rb:193:in
`build_extension'
/Users/khoi/.rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/ext/builder.rb:227:in `block
in build_extensions'
  /Users/khoi/.rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/ext/builder.rb:224:in `each'
/Users/khoi/.rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/ext/builder.rb:224:in
`build_extensions'
/Users/khoi/.rubies/ruby-3.3.5/lib/ruby/3.3.0/rubygems/installer.rb:853:in
`build_extensions'
/Users/khoi/.gem/ruby/3.3.5/gems/bundler-2.4.15/lib/bundler/rubygems_gem_installer.rb:72:in
`build_extensions'
/Users/khoi/.gem/ruby/3.3.5/gems/bundler-2.4.15/lib/bundler/rubygems_gem_installer.rb:28:in
`install'
/Users/khoi/.gem/ruby/3.3.5/gems/bundler-2.4.15/lib/bundler/source/rubygems.rb:201:in
`install'
/Users/khoi/.gem/ruby/3.3.5/gems/bundler-2.4.15/lib/bundler/installer/gem_installer.rb:54:in
`install'
/Users/khoi/.gem/ruby/3.3.5/gems/bundler-2.4.15/lib/bundler/installer/gem_installer.rb:16:in
`install_from_spec'
/Users/khoi/.gem/ruby/3.3.5/gems/bundler-2.4.15/lib/bundler/installer/parallel_installer.rb:156:in
`do_install'
/Users/khoi/.gem/ruby/3.3.5/gems/bundler-2.4.15/lib/bundler/installer/parallel_installer.rb:147:in
`block in worker_pool'
/Users/khoi/.gem/ruby/3.3.5/gems/bundler-2.4.15/lib/bundler/worker.rb:62:in
`apply_func'
/Users/khoi/.gem/ruby/3.3.5/gems/bundler-2.4.15/lib/bundler/worker.rb:57:in `block
in process_queue'
  <internal:kernel>:187:in `loop'
/Users/khoi/.gem/ruby/3.3.5/gems/bundler-2.4.15/lib/bundler/worker.rb:54:in
`process_queue'
/Users/khoi/.gem/ruby/3.3.5/gems/bundler-2.4.15/lib/bundler/worker.rb:90:in `block
(2 levels) in create_threads'

An error occurred while installing eventmachine (1.2.7), and Bundler cannot
continue.

In Gemfile:
  minima was resolved to 2.5.1, which depends on
    jekyll-feed was resolved to 0.17.0, which depends on
      jekyll was resolved to 4.3.2, which depends on
        em-websocket was resolved to 0.5.3, which depends on
          eventmachine

What should I do?

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

this usually is cause ruby doesn’t have the dev tools installed. Did you make any changes to ruby since it last worked?

are you using a ruby version manager? rvm? you might have it set to the wrong version of ruby? if you run rvm list does it give you a list of rubys or an error?

I’m not a mac user so not too sure what is happening. But the first line is also saying the lockfile was generated with an older version of bundler which could also mean the last time you ran it it used an older version of ruby but that is a bit of a guess.

I’d try to simply delete the lock file; that has helped me in similar situations. It will be regenerated.

Hi, thanks for your response.

I made some changes that I don’t remember and are not recorded by git. The first time it was broken was a few weeks ago, which I did not resolve immediately.

I am not using rvm or so. I remember installing Jekyll using homebrew. I tried deleting the lock file and run bundle install again, but I got the same error at eventmachine.

I tried deleting the lock file then bundle install, but I got the same error.

my guess is something changed with ruby somehow and you don’t have the build tools needed to build some gems. On windows there are usually 2 ways to install ruby, one with the build tools and one without. If you do the one without you get that type of error.

Google the main error : Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

and your os to see options.

On macs sometimes people end up with ruby installed multiple times - like a system ruby and then a user ruby though you can usually see that in the logs and yours look ok to me but I could be wrong.

Maybe the ruby manager is called rbenv? do you use that?

I’m having the same problem.

The only thing that’s changed was I upgraded from MacOS 14.xx to 15.1 (Sonoma). I’m guessing there’s some change in MacOS - but it’s beyond my skill to figure this out.

Hopefully someone can post a solution – otherwise I can’t update my website. Ack.

Thanks,

david,

i think it might have something to do with xcode, but as a windows user i don’t know what that is. Google mac os ruby xcode and you should come up with a lot of posts.

I’m having the same error here. On MacOS 15.2 (Sequoia), tried using rbenv, chruby but still got the same make error when compiling binder.cpp. Did anyone figure out the solution here?

I have another suggestion, try to setup your environment using docker with a linux image. This way it is way more stable, the error can be reproducible, and also there are a lot more users that may be able to help you.

You can even use devcontainers, which I think is a nice solution. Plus, you have the added bonus of being able to set a GitHub Codespace hassle free, and there’s even a free tier with limits.

There are 2 projects that use Jekyll and support devcontainers that I know. This first one is in PT-BR, but you can see the devcontainer setup here (which is simpler) and the link to create your own GitHub codespaces based on it in its documentation. The other one is a little more complicated (the file I mean, not to use it), which is this template site. You can check its devcontainer setup here.

Today I ran into the same issue where the eventmachine fails after “compiling binder.cpp”
I went to the directory it says it was trying to build and ran the make command it shows myself and got the same error. The Makefile has a verbose mode which I enabled which showed me the command it was trying to run. Also, the Makefile strangely has the following which appears like it could not find a C++ compiler to use:
CC = clang
CXX = false
In my system (latest Sequoia 16.2 with the latest Xcode installed), I have both cc and c++ available at the terminal.

I ran the compile line that failed using clang and got the same error, and the entire make works when I edit the Makefile to have CXX = c++

So the issue appears to be related to the C++ compiler either not being detected or not being selected for some reason.

I tried a few things suggested by this link, but it appears not to help: c++ - The CXX compiler identification is unknown: xcode - Stack Overflow

Solution is here: eventmachine(1.2.7) installation issue on Intel mac with ruby 3.3.0 · Issue #990 · eventmachine/eventmachine · GitHub

My guess is that the C++ compiler on your system is autodetected while installing Ruby and it doesn’t check again, if something about it is not setup right at that point, then subsequent gem installs that require it, like eventmachine, won’t work.

This is why the fix is two steps: uninstall Ruby, get the Apple command-line tools setup properly and working properly (FYI - some folks are having to accept the Apple license), then re-install Ruby.

You can tell that Ruby has found your C++ compiler properly by typing this in a terminal:
ruby -rrbconfig -e 'puts RbConfig::CONFIG["CXX"]'
It should show clang++