thumb

This happened to me after upgrading MacOS to version “High Sierra” on my MacBook. I cloned my application repository and went to execute a bundle install command, but it throws the following error message:

bundle install
Fetching gem metadata from https://rubygems.org/.........
Using i18n 0.8.4
Using minitest 5.10.2
Using thread_safe 0.3.6
Using tzinfo 1.2.3
Using activesupport 4.2.8
Using addressable 2.4.0
Using bundler 1.16.0.pre.3
Using coffee-script-source 1.12.2
Using execjs 2.7.0
Using coffee-script 2.4.1
Using colorator 0.1
Fetching ffi 1.9.18


Your user account isn't allowed to install to the system RubyGems.
  You can cancel this installation and run:

      bundle install --path vendor/bundle

  to install the gems into ./vendor/bundle/, or you can enter your password
  and install the bundled gems to RubyGems using sudo.

  Password:

So I tried to enter password and install the bundled gems to RubyGems using sudo. But this did not solve the problem and here’s what I saw:

  Password:

Installing ffi 1.9.18 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /private/var/folders/9h/m_3snmy15mg05l5y6n86pp7h0000gn/T/bundler20171007-1346-1m3bsqgffi-1.9.18/gems/ffi-1.9.18/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20171007-1346-t80q5.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/folders/9h/m_3snmy15mg05l5y6n86pp7h0000gn/T/bundler20171007-1346-1m3bsqgffi-1.9.18/gems/ffi-1.9.18 for
inspection.
Results logged to
/var/folders/9h/m_3snmy15mg05l5y6n86pp7h0000gn/T/bundler20171007-1346-1m3bsqgffi-1.9.18/extensions/universal-darwin-17/2.3.0/ffi-1.9.18/gem_make.out

An error occurred while installing ffi (1.9.18), and Bundler cannot continue.
Make sure that `gem install ffi -v '1.9.18'` succeeds before bundling.

In Gemfile:
  github-pages was resolved to 78, which depends on
    github-pages-health-check was resolved to 1.1.0, which depends on
      typhoeus was resolved to 0.8.0, which depends on
        ethon was resolved to 0.10.1, which depends on
          ffi

In this error message, we are prompted to install the gem ffi by using the following command:

gem install ffi -v '1.9.18'
Building native extensions. This could take a while...
ERROR:  Error installing ffi:
    ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.18/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20171007-1375-ozw0u1.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.18 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/ffi-1.9.18/gem_make.out

This did not help, and the same with the use of sudo. Then I decided to try set a location other than my system’s gem repository. Moreover, in the first error message we were asked about this option.

bundle install --path vendor/bundle
Fetching gem metadata from https://rubygems.org/.........
Fetching i18n 0.8.4
Installing i18n 0.8.4
Fetching minitest 5.10.2
Installing minitest 5.10.2
Fetching thread_safe 0.3.6
...
Fetching terminal-table 1.8.0
Installing terminal-table 1.8.0
Fetching github-pages 78
Installing github-pages 78
Bundle complete! 1 Gemfile dependency, 51 gems now installed.
Bundled gems are installed into `./vendor/bundle`
Post-install message from html-pipeline:
-------------------------------------------------
Thank you for installing html-pipeline!
You must bundle Filter gem dependencies.
See html-pipeline README.md for more details.
https://github.com/jch/html-pipeline#dependencies
-------------------------------------------------
Post-install message from github-pages:
---------------------------------------------------
Thank you for installing github-pages!
GitHub Pages recently upgraded to Jekyll 3.0, which
includes some breaking changes. More information:
https://github.com/blog/2100-github-pages-jekyll-3
---------------------------------------------------

Looks good. Let’s now try to run the bundle install command:

bundle install
Using i18n 0.8.4
Using minitest 5.10.2
Using thread_safe 0.3.6
Using tzinfo 1.2.3
Using activesupport 4.2.8
...
Using jekyll-redirect-from 0.10.0
Using jekyll-seo-tag 1.4.0
Using jekyll-sitemap 0.10.0
Using jemoji 0.6.2
Using unicode-display_width 1.2.1
Using terminal-table 1.8.0
Using github-pages 78
Bundle complete! 1 Gemfile dependency, 51 gems now installed.
Bundled gems are installed into `./vendor/bundle`

And it worked.

Conclusion

That’s it, you’re done. So simple isn’t it?

If you are having trouble fixing this problem with the instructions above, but are being able to solve this problem with any another method please describe it in the comment section below. Thanks!

If this article has helped you solve the problem then please leave a comment :smiley:

Thanks for reading!