Trouble installing jekyll with rbenv and trouble installing RVM

Hi all,

I’ve been trying to install Jekyll lately and I’ve had no luck. I’ve followed the jekyll installation guides, and gone down plenty of rabbit holes on stack overflow, etc. I’m not the most technical person so once I get into bash profile, and configure logs, etc. I’m lost. Here are the details…

I’m using all the current software (MacOS Big Sur 11.1), xcode 12.3, xcode CommandLineTools 12.3. (Both downloaded from apple development site) Ruby 3.0.0, rbenv 1.1.2, gcc 7.5.0. (All 3 downloaded from homebrew).

I’ve tried to install jekyll with rbenv. When I use rbenv, I get an error saying “ERROR: Failed to build gem native extension”. There were answers on google/stack overflow saying to add certain code snippets to my bash profile, but that didn’t seem to work.

I also saw a post saying the native extension error was common was rbenv, so I decided to try with RVM. When I try to get RVM installed, I get…

“Error running ‘env CFLAGS=-O3 -I/usr/local/opt/libyaml/include -I/usr/local/opt/libksba/include -I/usr/local/opt/readline/include -I/usr/local/opt/zlib/include -I/usr/local/opt/openssl@1.1/include LDFLAGS=-L/usr/local/opt/libyaml/lib -L/usr/local/opt/libksba/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/zlib/lib -L/usr/local/opt/openssl@1.1/lib ./configure --prefix=/Users/Matt/.rvm/rubies/ruby-3.0.0 --disable-install-doc --enable-shared’,
please read /Users/Matt/.rvm/log/1609691282_ruby-3.0.0/configure.log
There has been an error while running configure. Halting the installation”

Configure.log has a section…

tool/config.guess already exists
tool/config.sub already exists
checking build system type… x86_64-apple-darwin20.2.0
checking host system type… x86_64-apple-darwin20.2.0
checking target system type… x86_64-apple-darwin20.2.0
checking for ld… ld
checking for gcc-ar… no
checking for g++… g++
checking for gcc-nm… no
checking for gcc-ranlib… no
checking for gcc… gcc
checking whether the C compiler works… no
configure: error: in /Users/Matt/.rvm/src/ruby-3.0.0': configure: error: C compiler cannot create executables See config.log’ for more details

I opened config.log, but I don’t know what to be looking at. Related to the lines above, These ‘checks’ were also done when I tried installing jekyll with rbenv. When I use gcc -v in my command line to look at the configuration, I see…

–with-sysroot=/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk

Since I’m on Big Sur (11.1), I don’t have the option for 10.14.sdk.

My questions are

  1. Could this be the reason my jekyll and RVM installs are failing? It seems like in the checks, some gcc stuff isn’t being found. I don’t know if this is the reason, but it’s my best guess.
  2. If so, how do I fix it? I’ve tried running different commands to change the sysroot to 11.1, but I get errors saying invalid option or no input files.

I feel like I’m out of my league at this point. Any help would be greatly appreciated. Thanks!

And what’s exactly the issue installing Jekyll specifically?

But if you already installed Ruby using brew, why do you need rbenv or rvm?

Do you need multiple versions of Ruby? That’s what rbenv and rvm are for.

If running the following command in your terminal:

ruby -v

Gives you something like:

ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-linux]

Then you are all set with Ruby, then you can install Jekyll.

I wouldn’t recommend executing random commands you see on internet, it might cause more issues than benefits.

I appreciate the reply Alfredo.

I uninstalled rbenv from homebrew. Since it was in the jekyll installation doc, I assumed it was needed. At this point when i run ‘ruby -v’, the result is ‘ruby 3.0.0.’

Now that I have rbenv uninstalled, I ran ‘gem install --user-install jekyll’. I get this error, ‘failed to build gem native extension’…

Building native extensions. This could take a while...

ERROR: Error installing jekyll:

ERROR: Failed to build gem native extension.

current directory: /Users/Matt/.gem/ruby/3.0.0/gems/ffi-1.14.2/ext/ffi_c

/usr/local/opt/ruby/bin/ruby -I /usr/local/lib/ruby/site_ruby/3.0.0 -r ./siteconf20210103-11328-bovlq5.rb extconf.rb

checking for ffi_prep_closure_loc() in -lffi... no

checking for ffi_prep_closure_loc() in -llibffi... no

checking for ffi_prep_closure_loc() in -llibffi-8... no

checking for whether -Wl,--exclude-libs,ALL is accepted as LDFLAGS... no

creating extconf.h

creating Makefile

current directory: /Users/Matt/.gem/ruby/3.0.0/gems/ffi-1.14.2/ext/ffi_c

make DESTDIR\= clean

current directory: /Users/Matt/.gem/ruby/3.0.0/gems/ffi-1.14.2/ext/ffi_c

make DESTDIR\=

Configuring libffi

configure: error: in `/Users/Matt/.gem/ruby/3.0.0/gems/ffi-1.14.2/ext/ffi_c/libffi-x86_64-darwin20':

configure: error: C++ preprocessor "/lib/cpp" fails sanity check

See `config.log' for more details

make: *** ["/Users/Matt/.gem/ruby/3.0.0/gems/ffi-1.14.2/ext/ffi_c/libffi-x86_64-darwin20"/.libs/libffi_convenience.a] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/Matt/.gem/ruby/3.0.0/gems/ffi-1.14.2 for inspection.

Results logged to /Users/Matt/.gem/ruby/3.0.0/extensions/x86_64-darwin-20/3.0.0/ffi-1.14.2/gem_make.out

It’s the same error I had in my original post. I’ve searched plenty of stack overflow and google responses with different solutions (uninstalling/reinstalling Xcode and CommandLineTools, adding different PATHs to my bash profile, but nothing seems to work.

Matt

Try the solution from this comment by the user ffleming.

brew reinstall libffi
export LDFLAGS="-L/usr/local/opt/libffi/lib"
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig"
gem install jekyll

Seems to be an issue specific to MacOS users, so unfortunately I can’t help further since I’m a GNU/Linux user.

After adding those paths to your ~/.bash_profile file you need to log out and log in again, or use the source command (only once), so the changes to the PATH environment variable are reflected.

source ~/.bash_profile

First of all, THANK YOU SO MUCH for sharing that. I’ve spent the better part of 3 days trying to figure out how to make this work. That allowed me to install Jekyll.

I’m running into a different problem now. I’m going through the jekyll quickstart, and I can’t seem to run anything.

(base) Matthews-MacBook-Pro:~ Matt$ jekyll new myblog

/usr/local/lib/ruby/site_ruby/3.0.0/rubygems.rb:281:in `find_spec_for_exe': **can't find gem jekyll (>= 0.a) with executable jekyll (** **Gem::GemNotFoundException** **)**

from /usr/local/lib/ruby/site_ruby/3.0.0/rubygems.rb:300:in `activate_bin_path'

from /Users/Matt/.gem/ruby/3.0.0/bin/jekyll:23:in `<main>'

I’m hoping someone has an idea of why this might be happening (Based on other posts, I think it may be something related to my gem paths? If I run ‘gem env’ I get this…

RubyGems Environment:
  - RUBYGEMS VERSION: 3.2.4
  - RUBY VERSION: 3.0.0 (2020-12-25 patchlevel 0) [x86_64-darwin20]
  - INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/3.0.0
  - USER INSTALLATION DIRECTORY: /Users/Matt/.gem/ruby/3.0.0
  - RUBY EXECUTABLE: /usr/local/opt/ruby/bin/ruby
  - GIT EXECUTABLE: /usr/local/bin/git
  - EXECUTABLE DIRECTORY: /usr/local/lib/ruby/gems/3.0.0/bin
  - SPEC CACHE DIRECTORY: /Users/Matt/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /usr/local/Cellar/ruby/3.0.0_1/etc
  - RUBYGEMS PLATFORMS:
     - ruby
     - x86_64-darwin-20
  - GEM PATHS:
     - /usr/local/lib/ruby/gems/3.0.0
     - /Users/Matt/.gem/ruby/3.0.0/bin
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /opt/local/bin
     - /opt/local/sbin
     - /opt/anaconda3/bin
     - /opt/anaconda3/condabin
     - /Library/Frameworks/Python.framework/Versions/3.7/bin
     - /Library/Frameworks/Python.framework/Versions/3.6/bin
     - /Users/Matt/.gem/ruby/3.0.0/bin
     - /usr/local/opt/ruby/bin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /Library/Apple/usr/bin

I thought I saw somewhere that you’re only supposed to have 1 gem path. Regardless, I can at least start researching this issue, now that I was able to install Jekyll.

If you have thoughts on this, they’re appreciated. If not, Thanks again for that code above.

Matt

in this topic:

it says ruby 3.x will give you trouble. Try using 2.7.

When you see the message about failing to build native extensions that can be because you don’t have the ruby devkit.

1 Like

Agree with comment above. Stick to Ruby 2.7

brew install ruby@2.7

Based on formula: https://formulae.brew.sh/formula/ruby

Here’s my goto guide for mac

Nice, but you might want to correct the typo
bundle exec jekyll build --tracd

bundle exec jekyll build --trace

Oops, thanks @michaelbach

Appreciate the replies everyone. We’re making progress, but not fully there yet!

I’m able to create a jekyll project now. I think the GEMPATH line in @MichaelCurrin’s response solved the issue I was having.

(base) Matthews-MacBook-Pro:~ Matt$ jekyll new myblog
Running bundle install in /Users/Matt/myblog... 
  Bundler: Bundle complete! 0 Gemfile dependencies, 1 gem now installed.
  Bundler: Use `bundle info [gemname]` to see where a bundled gem is installed.The Gemfile specifies no dependencies
New jekyll site installed in /Users/Matt/myblog. 

HOWEVER, I now run into this…

(base) Matthews-MacBook-Pro:~ Matt$ cd myblog
(base) Matthews-MacBook-Pro:myblog Matt$ bundle exec jekyll serve
Could not find gem 'minima (~> 2.5)' in any of the gem sources listed in your Gemfile.
Run `bundle install` to install missing gems.

I was running the ‘bundle exec’ line since that was the last step of the jekyll installation guide. I then looked at @MichaelCurrin’s macOS guide from his response.

At this point, his next step was

4. Install project-scoped gems

  1. Add these two gems to your Gemfile .

gem “jekyll’, '~> 3.9” gem “kramdown-parser-gfm”, "~> 1.1.0’

I have jekyll 4.2, so I tried running gem “jekyll’, '~> 4.2” (I also tried with 3.9, and with minima as the error says). When I run it, I get…

ERROR:  While executing gem ... (Gem::CommandLineError)
    Unknown command jekyll', '~> 4.2

I do have CommandLineTools installed, as well as Xcode. 12.3 for both.

After making version changes in your Gemfile, you need to run:

bundle update

That will install any missing gems, like the one the error message says.

You are mixing double quotes and single quotes, use just single quotes or just double quotes.

gem 'jekyll', '~> 3.9'
gem 'kramdown-parser-gfm', '~> 1.1.0'

or

gem 'jekyll', '~> 4.2'

It’s two quoted strings separated by a comma. If you use the syntax highlighter, you’ll notice the error.

gem “jekyll’, '~> 3.9”
gem “kramdown-parser-gfm”, "~> 1.1.0’
1 Like

GOT IT TO WORK :partying_face::tada::partying_face::tada::partying_face::tada::partying_face::tada:

Thanks for the help everyone :pray: :pray: :pray: :pray: :pray:

2 Likes