Can't install jekyll macOS Big Sur 11.2.3 (Library not loaded: @rpath/libffi.7.dylib (LoadError))

Hi
I tried to install Jekyll by following the manual (Jekyll on macOS | Jekyll • Simple, blog-aware, static sites), but I failed.

ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-darwin20]

macOS Big Sur 11.2.3

 gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 3.2.3
  - 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/zhaofei/.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/zhaofei/.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/zhaofei/.gem/ruby/3.0.0
     - /usr/local/Cellar/ruby/3.0.0_1/lib/ruby/gems/3.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/opt/ruby/bin
     - /usr/local/lib/ruby/gems/3.0.0/bin
     - /Applications/calibre.app/Contents/MacOS
     - /usr/local/sbin
     - /usr/local/gfortran/bin
     - /usr/local/opt/grep/libexec/gnubin
     - /usr/local/opt/coreutils/libexec/gnubin
     - /Users/zhaofei/.rbenv/shims
     - /usr/local/opt/ruby/bin
     - /usr/local/lib/ruby/gems/3.0.0/bin
     - /Applications/calibre.app/Contents/MacOS
     - /usr/local/sbin
     - /usr/local/gfortran/bin
     - /usr/local/opt/grep/libexec/gnubin
     - /usr/local/opt/coreutils/libexec/gnubin
     - /Applications/calibre.app/Contents/MacOS
     - /usr/local/sbin
     - /usr/local/gfortran/bin
     - /usr/local/opt/grep/libexec/gnubin
     - /usr/local/opt/coreutils/libexec/gnubin
     - /Applications/calibre.app/Contents/MacOS
     - /usr/local/sbin
     - /Users/zhaofei/miniconda3/bin
     - /Users/zhaofei/miniconda3/condabin
     - /usr/local/gfortran/bin
     - /usr/local/opt/grep/libexec/gnubin
     - /usr/local/opt/coreutils/libexec/gnubin
     - /usr/local/bin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /Library/TeX/texbin
     - /opt/X11/bin

jekyll --version

<internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': dlopen(/usr/local/lib/ruby/gems/3.0.0/gems/ffi-1.15.0/lib/ffi_c.bundle, 9): Library not loaded: @rpath/libffi.7.dylib (LoadError)
  Referenced from: /usr/local/lib/ruby/gems/3.0.0/gems/ffi-1.15.0/lib/ffi_c.bundle
  Reason: image not found - /usr/local/lib/ruby/gems/3.0.0/gems/ffi-1.15.0/lib/ffi_c.bundle
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /usr/local/lib/ruby/gems/3.0.0/gems/ffi-1.15.0/lib/ffi.rb:6:in `rescue in <top (required)>'
	from /usr/local/lib/ruby/gems/3.0.0/gems/ffi-1.15.0/lib/ffi.rb:3:in `<top (required)>'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /usr/local/lib/ruby/gems/3.0.0/gems/sassc-2.4.0/lib/sassc/native.rb:3:in `<top (required)>'
	from /usr/local/lib/ruby/gems/3.0.0/gems/sassc-2.4.0/lib/sassc.rb:31:in `require_relative'
	from /usr/local/lib/ruby/gems/3.0.0/gems/sassc-2.4.0/lib/sassc.rb:31:in `<top (required)>'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-sass-converter-2.1.0/lib/jekyll/converters/scss.rb:3:in `<top (required)>'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-sass-converter-2.1.0/lib/jekyll-sass-converter.rb:4:in `<top (required)>'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /Users/zhaofei/.gem/ruby/3.0.0/gems/jekyll-4.2.0/lib/jekyll.rb:195:in `<top (required)>'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /Users/zhaofei/.gem/ruby/3.0.0/gems/jekyll-4.2.0/exe/jekyll:8:in `<top (required)>'
	from /usr/local/lib/ruby/gems/3.0.0/bin/jekyll:23:in `load'
	from /usr/local/lib/ruby/gems/3.0.0/bin/jekyll:23:in `<main>'
<internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require': cannot load such file -- 3.0/ffi_c (LoadError)
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /usr/local/lib/ruby/gems/3.0.0/gems/ffi-1.15.0/lib/ffi.rb:4:in `<top (required)>'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /usr/local/lib/ruby/gems/3.0.0/gems/sassc-2.4.0/lib/sassc/native.rb:3:in `<top (required)>'
	from /usr/local/lib/ruby/gems/3.0.0/gems/sassc-2.4.0/lib/sassc.rb:31:in `require_relative'
	from /usr/local/lib/ruby/gems/3.0.0/gems/sassc-2.4.0/lib/sassc.rb:31:in `<top (required)>'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-sass-converter-2.1.0/lib/jekyll/converters/scss.rb:3:in `<top (required)>'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /usr/local/lib/ruby/gems/3.0.0/gems/jekyll-sass-converter-2.1.0/lib/jekyll-sass-converter.rb:4:in `<top (required)>'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /Users/zhaofei/.gem/ruby/3.0.0/gems/jekyll-4.2.0/lib/jekyll.rb:195:in `<top (required)>'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from <internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require'
	from /Users/zhaofei/.gem/ruby/3.0.0/gems/jekyll-4.2.0/exe/jekyll:8:in `<top (required)>'
	from /usr/local/lib/ruby/gems/3.0.0/bin/jekyll:23:in `load'
	from /usr/local/lib/ruby/gems/3.0.0/bin/jekyll:23:in `<main>'

I have tried brew reinstall libffi, didn’t work.

I see two errors on packages.

  • libffi
  • ffi_c

Those are dylib and .c files so you can try installing dev libraries that support Ruby.

xcode-select --install

Or see if you can install as gems instead if with Homebrew.

gem install ffi --user-install
# or
sudo gem install ffi

From ffi repo docs - Install

That is backed up by this
With the same error as yours and same solution as mine. You can try uninstall ffi then install ffi

Thanks, Michael

I try gem install ffi --user-install but doesn’t work, and xcode-select --install show xcode-select: error: command line tools are already installed

Hmm I don’t know.

I saw you originally did a brew reinstall variaion of this,

brew install libffi

And that solved someone’s issue here

A comment there does uninstall and install and sets shell config vars here

And another does

brew install libffi
brew link libffi

fwiw - I am on bigSur 11.2.3 and libffi is not symlinked from brew:

/usr/local/Cellar/libffi/3.3_3 (17 files, 540.3KB)
Poured from bottle on 2021-03-10 at 22:03:39
From: https://github.com/Homebrew/homebrew-         core/blob/HEAD/Formula/libffi.rb
License: MIT
==> Options
--HEAD
Install HEAD version
 ==> Caveats
libffi is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version    in
parallel can cause all kinds of trouble.

machine:~ roadie$ gem list ffi

*** LOCAL GEMS ***

ffi (1.15.0, 1.14.2, 1.13.1, 1.12.2, 1.11.3)
public_suffix (4.0.6, 4.0.5, 4.0.4, 4.0.3, 4.0.2, 2.0.5)

/Users/roadie/.rvm/gems/ruby-2.7.0/gems/ffi-1.12.2/ext/ffi_c/libffi-x86_64-darwin19/.libs/libffi.7.dylib

The problem may be in path.

The error trace alternates between gems in the Cellar for Homebrew. And the global Ruby :confused:

As below.

internal:/usr/local/Cellar/ruby/3.0.0_1/lib/ruby/3.0.0/rubygems

/usr/local/lib/ruby/gems/3.0.0/gems/..

Also the 3.0.0_1 seems weird.

Maybe do a clean removal of Homebrew Ruby with

brew uninstall ruby

And manually deleting dirs.

rm -rf /usr/local/Cellar/ruby/*

Then install again.

brew install ruby

Even ruby@2.7

Hi, I reinstall ruby@2.7 and also try something like macos - No package 'libffi' found in Homebrew Virtual Environment - Ask Different

It’s still doesn’t work. I’ll give up solving this problem for now

Hi, I reinstall ruby@2.7 and also try something like macos - No package ‘libffi’ found in Homebrew Virtual Environment - Ask Different

It’s still doesn’t work. I’ll give up solving this problem for now

You could try to install rvm (I use that and it works, I use ruby 2.7 but rvm lets you switch ruby versions easily per project)

https://rvm.io/rvm/install

Have a look at it and see if you like it. (of course install the stable version if you do)

Thanks.
I have tried rvm, still the same error message.

/Users/zhaofei/.rbenv/versions/2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': dlopen(/Users/zhaofei/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/ffi-1.12.2/lib/ffi_c.bundle, 9): Library not loaded: @rpath/libffi.7.dylib (LoadError)
  Referenced from: /Users/zhaofei/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/ffi-1.12.2/lib/ffi_c.bundle
  Reason: image not found - /Users/zhaofei/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/ffi-1.12.2/lib/ffi_c.bundle

I think there may still be a key issue that has not been addressed. I plan to stop using Jekyll for now and switch to a different type of tool.
Thanks again for all your help.!

That is not rvm - but rbenv - I remember choosing rvm when I had to decide which one to use for some reason, not sure which. (most prefer rbenv though I think).
I hope you find the error and if you do let us know. :slight_smile:

FWIW: I had similar error messages after switching to Ruby 3, and could never trace down what they meant in spite of intensive research. The went away after I deleted the ~/gems folder, which is automatically rebuilt.

1 Like

I don’t have a gems folder in the home directory. What is it for?

Is it not ~/.gem with a dot and no “s”?

It has gems installed for the user for use across projects or as shell tools. Like I run rufo to format my scripts without installing rufo in every Ruby project or mine.

Other users cannot access the gems.

While a path in /usr/... has a place for shared gems is accessible for all users to read. Like if you had multiple people using a machine or some user created to manage serving files on an a remote ubuntu machine. The problem is you need root access to write to that directory. Or you need to use root access to change permissions so that any user can edit that directory. Which is fine if you are the only person using your laptop or remote machine.

yes it is - I have that. It has ruby 2.6 and 2.7 and specs from hashicorp for the vagrant box and from rubygems.org

Actually, I have both directories… And ./gems is quite populated and very different from ~/.gem. Ah, I see how this comes about: in my bash profile I have
export GEM_HOME=$HOME/gems
export PATH="$HOME/gems/bin:$PATH"
So your gems are probably installed elsewhere.
Please ignore my comment then, sorry if I created confusion.