eventmachine does not compile on mac m2 · Issue #1010 · eventmachine/eventmachine · GitHub
Skip to content

eventmachine does not compile on mac m2 #1010

Open

Description

@texdade

Hello, trying to help a colleague out here that is not able to install eventmachine on his laptop:

current directory: /Users/colleague/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/eventmachine-1.0.9.1/ext
/Users/colleague/.rbenv/versions/3.3.5/bin/ruby extconf.rb --with-opt-dir\=/opt/homebrew/opt/openssl@1.1
checking for pkg-config for openssl... ["-I/opt/homebrew/Cellar/openssl@1.1/1.1.1w/include ", "-L/opt/homebrew/Cellar/openssl@1.1/1.1.1w/lib", "-lssl -lcrypto"]
-----
Using OpenSSL from pkg-config -I/opt/homebrew/Cellar/openssl@1.1/1.1.1w/include  && -L/opt/homebrew/Cellar/openssl@1.1/1.1.1w/lib && -lssl -lcrypto
-----
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 ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... 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 rb_thread_fd_select()... yes
checking for rb_fdset_t in ruby/intern.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 rb_wait_for_single_fd()... yes
checking for rb_enable_interrupt()... no
checking for rb_time_new()... yes
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/colleague/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/eventmachine-1.0.9.1/ext
make DESTDIR\= sitearchdir\=./.gem.20241009-26955-cwtrvv sitelibdir\=./.gem.20241009-26955-cwtrvv clean
current directory: /Users/colleague/.rbenv/versions/3.3.5/lib/ruby/gems/3.3.0/gems/eventmachine-1.0.9.1/ext
make DESTDIR\= sitearchdir\=./.gem.20241009-26955-cwtrvv sitelibdir\=./.gem.20241009-26955-cwtrvv
compiling binder.cpp
make: *** [binder.o] Error 1
make failed, exit code 2

Openssl is configured correctly, but I cannot figure out what is wrong :\ This happens also with version 1.2.7

Activity

  1. jlntrt commented on Oct 21, 2024

    @jlntrt

    I have the same issue on my M1 mac. It says fatal error: 'iostream' file not found. So I guess a dependency is missing?

    Full error output:

    Resolving dependencies...
    Installing eventmachine 1.2.7 with native extensions
    Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
    
        current directory: /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/eventmachine-1.2.7/ext
    /Users/<user>/.rbenv/versions/3.1.4/bin/ruby -I /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/3.1.0 extconf.rb --with-cppflags\=-I/opt/homebrew/opt/openssl@3/include
    -----
    Using OpenSSL from pkg-config -I/opt/homebrew/Cellar/openssl@3/3.3.2/include  && -L/opt/homebrew/Cellar/openssl@3/3.3.2/lib && -lssl -lcrypto
    -----
    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/<user>/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/eventmachine-1.2.7/ext
    make DESTDIR\= sitearchdir\=./.gem.20241021-50627-5gf1q0 sitelibdir\=./.gem.20241021-50627-5gf1q0 clean
    
    current directory: /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/eventmachine-1.2.7/ext
    make DESTDIR\= sitearchdir\=./.gem.20241021-50627-5gf1q0 sitelibdir\=./.gem.20241021-50627-5gf1q0
    compiling binder.cpp
    In file included from binder.cpp:20:
    ./project.h:25:10: fatal error: 'iostream' file not found
       25 | #include <iostream>
          |          ^~~~~~~~~~
    1 error generated.
    make: *** [binder.o] Error 1
    
    make failed, exit code 2
    
    Gem files will remain installed in /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/eventmachine-1.2.7 for inspection.
    Results logged to /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/extensions/arm64-darwin-23/3.1.0/eventmachine-1.2.7/gem_make.out
    
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/ext/builder.rb:102:in `run'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/ext/builder.rb:51:in `block in make'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/ext/builder.rb:43:in `each'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/ext/builder.rb:43:in `make'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:42:in `build'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/ext/builder.rb:171:in `build_extension'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/ext/builder.rb:205:in `block in build_extensions'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/ext/builder.rb:202:in `each'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/ext/builder.rb:202:in `build_extensions'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/installer.rb:843:in `build_extensions'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.6/lib/bundler/rubygems_gem_installer.rb:76:in `build_extensions'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.6/lib/bundler/rubygems_gem_installer.rb:28:in `install'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.6/lib/bundler/source/rubygems.rb:205:in `install'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.6/lib/bundler/installer/gem_installer.rb:54:in `install'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.6/lib/bundler/installer/gem_installer.rb:16:in `install_from_spec'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.6/lib/bundler/installer/parallel_installer.rb:132:in `do_install'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.6/lib/bundler/installer/parallel_installer.rb:123:in `block in worker_pool'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.6/lib/bundler/worker.rb:62:in `apply_func'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.6/lib/bundler/worker.rb:57:in `block in process_queue'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.6/lib/bundler/worker.rb:54:in `loop'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.6/lib/bundler/worker.rb:54:in `process_queue'
      /Users/<user>/.rbenv/versions/3.1.4/lib/ruby/gems/3.1.0/gems/bundler-2.5.6/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:
      guard-livereload was resolved to 2.5.2, which depends on
        em-websocket was resolved to 0.5.3, which depends on
          eventmachine
    
  2. MSP-Greg commented on Oct 21, 2024

    @MSP-Greg
    Contributor

    Is XCode installed?

    I just built both EM master and 1.2.7 using Ruby master. I use OpenSSL 3.3.2, but 1.1.1 should also work.

    I don't do much dev work on macOS. When I first tried to build/install EM, I also had failures. Looked at the GHA logs, and they referenced some XCode files. I don't think I've built any c++ gems that I recall, so I installed XCode, and rebuilt Ruby. EM then built/installed.

  3. jlntrt commented on Oct 22, 2024

    @jlntrt

    @MSP-Greg Thank you for your answer. I have just installed and started Xcode so that everything is initialized. Unfortunately still no success installing eventmachine.

  4. jakehlee commented on Oct 22, 2024

    @jakehlee

    First confirm that Xcode Command Line Tools are installed:

    % xcode-select -p
    

    If that doesn't return a path, you should run:

    % sudo xcode-select --install
    % softwareupdate --all --install --force
    

    Also, I see that you're using Homebrew, so make sure that Homebrew was installed with CLT linked:

    % brew config
    ...
    CLT: 16.0.0.0.1.1724870825
    

    If not, you may have to install CLT and reinstall Homebrew.

    If none of the above is the issue, then take a look at the thread I just responded to in #990.

  5. jlntrt commented on Oct 22, 2024

    @jlntrt

    Thank you. I switched from rbenv to asdf. Now it works fine.

  6. hoblin commented on Oct 29, 2024

    @hoblin

    Same fatal error: 'iostream' file not found problem on Intel Mac with RVM and asdf

    ❯ gem install eventmachine
    Building native extensions. This could take a while...
    ERROR:  Error installing eventmachine:
    	ERROR: Failed to build gem native extension.
    
        current directory: /Users/hoblin/.rvm/gems/ruby-2.7.8/gems/eventmachine-1.2.7/ext
    /Users/hoblin/.rvm/rubies/ruby-2.7.8/bin/ruby -I /Users/hoblin/.rvm/rubies/ruby-2.7.8/lib/ruby/2.7.0 -r ./siteconf20241030-74511-1kyqcez.rb extconf.rb
    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=-g -O2 -Wall -Wextra -Wno-deprecated-declarations -Wno-ignored-qualifiers -Wno-unused-result -Wno-address
    creating Makefile
    
    current directory: /Users/hoblin/.rvm/gems/ruby-2.7.8/gems/eventmachine-1.2.7/ext
    make "DESTDIR=" clean
    
    current directory: /Users/hoblin/.rvm/gems/ruby-2.7.8/gems/eventmachine-1.2.7/ext
    make "DESTDIR="
    compiling binder.cpp
    In file included from binder.cpp:20:
    ./project.h:25:10: fatal error: 'iostream' file not found
       25 | #include <iostream>
          |          ^~~~~~~~~~
    1 error generated.
    make: *** [binder.o] Error 1
    
    make failed, exit code 2
    
    Gem files will remain installed in /Users/hoblin/.rvm/gems/ruby-2.7.8/gems/eventmachine-1.2.7 for inspection.
    Results logged to /Users/hoblin/.rvm/gems/ruby-2.7.8/extensions/x86_64-darwin-24/2.7.0/eventmachine-1.2.7/gem_make.out

    Tried with Ruby 2.7, 3.0, and 3.2.

  7. xinghengwang commented on Nov 15, 2024

    @xinghengwang

    I remememd you guys see this: #1009

  8. hoblin commented on Nov 16, 2024

    @hoblin

    I found out what the problem was in my case.
    After upgrading to the macOS Sequoia 15.1 newly installed Ruby was getting CXX=false.

    1. Check if your Ruby is affected:
    ruby -rmkmf -e 'puts RbConfig::CONFIG["CXX"]'

    If it shows false instead of clang++, you need to reinstall Command Line Tools:

    1. Fix:
    sudo rm -rf /Library/Developer/CommandLineTools
    xcode-select --install
    1. After installation completes, reinstall Ruby using your version manager
  9. nevans commented on Nov 22, 2024

    @nevans
    Contributor

    Perhaps someone could submit a PR that adds a check to the top of ext/extconf.rb. We ought to make sure that CONFIG["CXX"] is something sane, and abort with helpful instructions if we know it isn't. For example, something like this maybe?

    case CONFIG["CXX"]
    when *known_good_cxx
    when "false", nil
      abort <<~ERROR
        ******************************************************************************
        **** Ruby is not configured with a working C++ compiler.
        **** Please install one of #{known_good_cxx.join(", ")}.
        **** #{os_specific_prerequisite_instructions}
        **** You may need to rebuild ruby after installing a C++ compiler.
        ******************************************************************************
      ERROR
    else
      warn <<~WARNING % [CONFIG["CXX"], known_good_cxx.join(", ")]
        **** Warning: Unknown whether CONFIG["CXX"] (%s) is a compatible C++ compiler.
        ****   If installation fails, you may need to install one of %s.
      WARNING
    end

    What do y'all think? I can make the PR. (I'm linux only, so I'll need to steal my spouse's Macbook. 😉) But I'm unsure about reasonable defs for known_good_cxx and os_specific_prerequisite_instructions. (ping: @MSP-Greg) I can just leave those out

  10. tagliala commented on Dec 11, 2024

    @tagliala

    Thanks @hoblin, this helped me too on macOS Sequoia 15.1 and M1 Pro

    Before

    $ ruby -rmkmf -e 'puts RbConfig::CONFIG["CXX"]'
    false
    

    After

    $ ruby -rmkmf -e 'puts RbConfig::CONFIG["CXX"]'
    g++ -std=gnu++11
    

    And now eventmachine compiles (again)

  11. georgeu2000 commented on Jan 20, 2025

    @georgeu2000
    1. Check if your Ruby is affected:

    ruby -rmkmf -e 'puts RbConfig::CONFIG["CXX"]'
    If it shows false instead of clang++, you need to reinstall Command Line Tools:

    1. Fix:

    sudo rm -rf /Library/Developer/CommandLineTools
    xcode-select --install
    3. After installation completes, reinstall Ruby using your version manager

    @hoblin - This worked for me on M1 Max running Sequoia 15.1.1 and using rbenv. Thank you.

    Don't forget to reinstall Ruby using your version manager

    Then I got

    > ruby -rmkmf -e 'puts RbConfig::CONFIG["CXX"]'
    clang++ -std=gnu++11
    
  12. emmahsax commented on Feb 13, 2025

    @emmahsax

    I first ran into this issue when upgrading a project to Ruby 3.4.1. Now, after running the process discussed above, using rbenv, then eventmachine compiles again and I can run bundle install.

  13. aavina commented on Feb 19, 2025

    @aavina

    Ditto here. I had Ruby 3.4.1 installed and I ran into the compilation issue after a MacOS upgrade. Following instructions did the trick. Thank you!

  14. gwholland3 commented on Mar 29, 2026

    @gwholland3

    Here to say that in 2026, #1010 (comment) fixed the issue for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions