ERROR: Error installing jekyll: ERROR: Failed to build gem native extension. How do I solve this problem?

gem install jekyll
Building native extensions. This could take a while…
ERROR: Error installing jekyll:
ERROR: Failed to build gem native extension.

current directory: /Users/chae/.rvm/gems/ruby-3.0.0/gems/eventmachine-1.2.7/ext

/Users/chae/.rvm/rubies/ruby-3.0.0/bin/ruby -I /Users/chae/.rvm/rubies/ruby-3.0.0/lib/ruby/3.0.0 -r ./siteconf20211224-36917-6ubxmo.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= -Wall -Wextra -Wno-deprecated-declarations -Wno-ignored-qualifiers -Wno-unused-result -Wno-address
creating Makefile

current directory: /Users/chae/.rvm/gems/ruby-3.0.0/gems/eventmachine-1.2.7/ext
make “DESTDIR=” clean

current directory: /Users/chae/.rvm/gems/ruby-3.0.0/gems/eventmachine-1.2.7/ext
make “DESTDIR=”
compiling binder.cpp
In file included from binder.cpp:20:
./project.h:119:10: fatal error: ‘openssl/ssl.h’ file not found
#include <openssl/ssl.h>
1 error generated.
make: *** [binder.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/chae/.rvm/gems/ruby-3.0.0/gems/eventmachine-1.2.7 for inspection.
Results logged to /Users/chae/.rvm/gems/ruby-3.0.0/extensions/arm64-darwin-21/3.0.0/eventmachine-1.2.7/gem_make.out

this usually has to do with not having the ruby devkit installed so it can’t build native extensions.

What OS are you on?
How did you install Ruby?

on windows there used to be 2 installers for ruby - one with the devkit and one without and you needed to install the one with the devkit for jekyll to work. I seem to remember something about this changing in the last year or 2 but not sure.

Hi! I always use docker to be sure every gem version is fine without conflicts and to be up faster.

This error is usually due to missing or broken command line tools, or a borked Ruby installation. I also see that you’re using RVM, which I don’t recommend these days. My preferred version manager is chruby because it’s the simplest and easiest to use.

Helping people set up Ruby and install gems on their Mac is my specialty. Over the past ten years, I’ve helped thousands of people. From clean Macs to the most obscure issues, I’ve seen and fixed it all. Of all the possible ways to install gems on a Mac, the most reliable solution I’ve found is to use a version manager, specifically chruby.

I wrote a detailed article that can help you properly install Ruby on a Mac.

thanks for the awesome information.