Search code examples
rubyrubygemsjekyllgithub-pages

Why is my jekyll command not working anymore?


I've recently discovered that the jekyll command doesn't work anymore on my computer, after perfectly using it for several months.

Whenever I try to run a jekyll command, it says:

/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs':
    Could not find 'jekyll' (>= 0) among 34 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/Mael/.gem/ruby/2.3.0:/Library/Ruby/Gems/2.3.0:/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0',
    execute `gem env` for more information
    from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/dependency.rb:328:in `to_spec'
    from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
    from /usr/local/bin/jekyll:22:in `<main>'

I'm on macOS Sierra (10.12.6).

Xcode is installed

I have Xcode installed on my computer:

$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

Reinstalling Jekyll

Checking ruby version and (re)installing bundler

So I tried reinstalling Jekyll as I did the first time:

$ ruby -v
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin16]

$ sudo gem install bundler
Successfully installed bundler-1.17.1
Parsing documentation for bundler-1.17.1
Done installing documentation for bundler after 4 seconds
1 gem installed

Creating a Gemfile

I created a Gemfile which contains:

gem 'github-pages'
source 'https://rubygems.org'

Bundle install (here come the issues)

And ran, in the directory that contains the Gemfile:

$ bundle install

Here, the installation doesn't work, it says:

An error occurred while installing commonmarker (0.17.13), and Bundler cannot continue.
Make sure that `gem install commonmarker -v '0.17.13' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  github-pages was resolved to 192, which depends on
    jekyll-commonmark-ghpages was resolved to 0.1.5, which depends on
      jekyll-commonmark was resolved to 1.2.0, which depends on
        commonmarker

So I tried the gem install commonmarker -v '0.17.13' --source 'https://rubygems.org/' command, and it says:

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

    current directory: /Library/Ruby/Gems/2.3.0/gems/commonmarker-0.17.13/ext/commonmarker
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20181112-6105-u9aca2.rb extconf.rb
creating Makefile

current directory: /Library/Ruby/Gems/2.3.0/gems/commonmarker-0.17.13/ext/commonmarker
make "DESTDIR=" clean

current directory: /Library/Ruby/Gems/2.3.0/gems/commonmarker-0.17.13/ext/commonmarker
make "DESTDIR="
make: *** No rule to make target `/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/include/ruby-2.3.0/universal-darwin16/ruby/config.h', needed by `arena.o'.  Stop.

make failed, exit code 2

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

I noticed that I have several jekyll and github-pages gems in my /Library/Ruby/Gems/2.0.0/gems (2.0.0) directory:

github-pages-146
github-pages-health-check-1.3.5
...
jekyll-3.4.5
jekyll-avatar-0.4.2
jekyll-coffeescript-1.0.1
[and several other jekyll directories]
...

But not in my /Library/Ruby/Gems/2.3.0/gems (2.3.0) directory! (the one which seems to be targeted by the GEM_PATH when running a jekyll command)

So, maybe I did something that changed the version or something. (I've recently installed osxfuse and sshfs (via brew), I don't know if it has anything to do with the issue?)

I don't know anything about Ruby, Gems system, and so on. Maybe the solution is obvious but I've tried several things with no success.

(Sorry it's a bit long but I wanted to be as clear as possible!)


Solution

  • I found a solution, that I think is very not clean, but works for now.

    I have two directories in /Library/Ruby/Gems/:

    • 2.0.0/
      • gems/
      • specifications/
      • ...
    • 2.3.0/
      • gems/
      • specifications/
      • ...

    The error output, when I try to run jekyll, tells that it checks (among others) in /Library/Ruby/Gems/2.3.0, but as I said in my question, there aren't any jekyll-related file in there.

    So, I manually copied all the files from /Library/Ruby/Gems/2.0.0/gems and /Library/Ruby/Gems/2.0.0/specifications and pasted them in /Library/Ruby/Gems/2.3.0/gems and /Library/Ruby/Gems/2.3.0/specifications respectively.

    I guess that the files I've copied are maybe outdated for the Ruby version I have (?), but it works perfectly.

    Maybe there is a more conventional way to make it work?