MacOS install of Jekyll with conda proving tricky

Hello. I posted this question as a github issue but was pointed here.

I would like to be able to install jekyll with a ruby installation under a conda environment (just for ease when switching projects). Unfortunately it looks like the version of ruby that you can install with conda does not come with openssl support.

Please may any conda/ruby aficionados help me diagnose and fix. They payoff would be a new and easy install method for your docs that is platform independent.

My Environment

Software Version(s)
Operating System OSX 10.14.5 (Mojave)
jekyll Latest
github-pages Latest

Expected Behaviour

I’m trying to make an environment for developing my website using conda. I appreciate this is not the way you recommend in your documentation, and I will move on to trying to use rbenv with brew now. But I’d be interested to know what is failing here; I believe I’ve satisfied requirements.

Current Behaviour

I end up getting the error:

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: *** [Makefile:234: binder.o] Error 1

make failed, exit code 2

When running the gem install

Code Sample

Here’s how to reproduce this issue and various versions etc.

$ conda --version
conda 4.7.5
$ conda create -n site python=3 ruby make clangxx_osx-64  # get clang error without clang install
$ ls ~/.gem/ruby/
2.0.0 2.4.0 2.5.0
$ echo 'export PATH=$HOME/.gem/ruby/2.5.0/bin:$PATH' >> ~/.bash_profile
$ source ~/.bash_profile
$ conda activate site
$ which ruby; ruby --version
~/miniconda3/envs/site/bin/ruby
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin14]
$ which gem; gem --version
~miniconda3/envs/site/bin/gem
2.7.6
$ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ g++ -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
$ make -v
GNU Make 4.2.1
Built for x86_64-apple-darwin17.4.0
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

And finally:

$ gem install --user-install bundler jekyll
Successfully installed bundler-2.0.2
Parsing documentation for bundler-2.0.2
Done installing documentation for bundler after 4 seconds
Building native extensions. This could take a while...
ERROR:  Error installing jekyll:
	ERROR: Failed to build gem native extension.

    current directory: ~/.gem/ruby/2.5.0/gems/eventmachine-1.2.7/ext
~/miniconda3/envs/site/bin/ruby -r ./siteconf20190704-10753-3m2ftk.rb extconf.rb
checking for -lcrypto... no
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... no
checking for rb_thread_fd_select()... no
checking for rb_fdset_t in ruby/intern.h... yes
checking for rb_wait_for_single_fd()... no
checking for rb_enable_interrupt()... no
checking for rb_time_new()... no
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... no
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()... no
checking for gethrtime()... no
CXXFLAGS=$(cxxflags) -Wall -Wextra -Wno-deprecated-declarations -Wno-ignored-qualifiers -Wno-unused-result -Wno-address
creating Makefile

current directory: ~/.gem/ruby/2.5.0/gems/eventmachine-1.2.7/ext
make "DESTDIR=" clean

current directory: ~/.gem/ruby/2.5.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: *** [Makefile:234: binder.o] Error 1

make failed, exit code 2

Gem files will remain installed in ~/.gem/ruby/2.5.0/gems/eventmachine-1.2.7 for inspection.
Results logged to ~/.gem/ruby/2.5.0/extensions/x86_64-darwin-14/2.5.0/eventmachine-1.2.7/gem_make.out
1 gem installed

Have also tried pointing to the openssl binaries

$ ls ~/miniconda3/envs/site/include/openssl/
... ssl.h ...
$ gem install --user-install bundler jekyll -- --with-cppflags=-I$HOME/miniconda3/envs/site/include/
... shedloads of warnings ...
ed.cpp:1126:22: error: use of undeclared identifier 'writev'; did you mean 'write'?
        int bytes_written = writev (GetSocket(), iov, iovcnt);
                            ^~~~~~
                            write
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/unistd.h:495:10: note: 'write' declared here
ssize_t  write(int __fd, const void * __buf, size_t __nbyte) __DARWIN_ALIAS_C(write);
         ^
... moar warnings ...
make failed, exit code 2

Gem files will remain installed in ~/.gem/ruby/2.5.0/gems/eventmachine-1.2.7 for inspection.
Results logged to ~/.gem/ruby/2.5.0/extensions/x86_64-darwin-14/2.5.0/eventmachine-1.2.7/gem_make.out
1 gem installed

Have now also tried separating these commands (as suggested at end of docs):

$ gem install bundler
success
$ gem install -n ~/miniconda3/envs/site/bin/ jekyll
...
checking for openssl/ssl.h... yes
...
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
...

You can try to install eventmachine gem with this command

gem install eventmachine -- --with-cppflags=-I$(brew --prefix openssl)/include

and than gem install jekyll

To configure bundle to build eventmachine on macOS with proper include flag

bundle config build.eventmachine --with-cppflags=-I$(brew --prefix openssl)/include