11

I tried to use Jekyll new command, but it didn't work and came out following errors.

$ jekyll new myblog
/Library/Ruby/Gems/1.8/gems/commander-4.1.6/lib/commander/runner.rb:385:in `require_program': program version required (Commander::Runner::CommandError)
from /Library/Ruby/Gems/1.8/gems/commander-4.1.6/lib/commander/runner.rb:384:in `each'
from /Library/Ruby/Gems/1.8/gems/commander-4.1.6/lib/commander/runner.rb:384:in `require_program'
from /Library/Ruby/Gems/1.8/gems/commander-4.1.6/lib/commander/runner.rb:52:in `run!'
from /Library/Ruby/Gems/1.8/gems/commander-4.1.6/lib/commander/delegates.rb:8:in `run!'
from /Library/Ruby/Gems/1.8/gems/commander-4.1.6/lib/commander/import.rb:10
from /usr/bin/jekyll:23
/Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `gem_original_require': no such file to load -- json (LoadError)
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/jekyll-1.4.3/bin/../lib/jekyll/filters.rb:2
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/jekyll-1.4.3/bin/../lib/jekyll.rb:44
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `gem_original_require'
from /Library/Ruby/Site/1.8/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Library/Ruby/Gems/1.8/gems/jekyll-1.4.3/bin/jekyll:7
from /usr/bin/jekyll:23:in `load'
from /usr/bin/jekyll:23

I'm using Mac OS X 10.8.5 Mountain Lion. I checked stackoverflow and found a post which has a similar problem. Error when running jekyll new command Then I tried the below command.

$ sudo gem install json

but It didn't work for my situation. I uninstalled and reinstalled json but nothing happened. Please let me know if you know any other solutions. I've been stuck on this problem since the beginning of the week...

my gem list & gem environment are as follows.

$ gem list

*** LOCAL GEMS ***

bigdecimal (1.2.4)
blankslate (2.1.2.4)
classifier (1.3.4)
colorator (0.1)
commander (4.1.6)
fast-stemmer (1.0.2)
ffi (1.9.3)
highline (1.6.21)
io-console (0.4.2)
jekyll (1.4.3)
json (1.8.1)
liquid (2.5.5)
listen (1.3.1)
maruku (0.7.1)
minitest (4.7.5)
parslet (1.5.0)
posix-spawn (0.3.8)
psych (2.0.3)
pygments.rb (0.5.4)
rake (10.1.0)
rb-fsevent (0.9.4)
rb-inotify (0.9.3)
rb-kqueue (0.2.2)
rdoc (4.1.0)
redcarpet (2.3.0)
safe_yaml (0.9.7)
test-unit (2.1.1.0)
toml (0.1.1)
yajl-ruby (1.1.0)

$ gem env

RubyGems Environment:
  - RUBYGEMS VERSION: 2.2.2
  - RUBY VERSION: 2.1.1 (2014-02-24 patchlevel 76) [x86_64-darwin12.0]
  - INSTALLATION DIRECTORY: /usr/local/Cellar/ruby/2.1.1/lib/ruby/gems/2.1.0
  - RUBY EXECUTABLE: /usr/local/Cellar/ruby/2.1.1/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/Cellar/ruby/2.1.1/bin
  - SPEC CACHE DIRECTORY: /Users/MyName/.gem/specs
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-12
  - GEM PATHS:
     - /usr/local/Cellar/ruby/2.1.1/lib/ruby/gems/2.1.0
     - /Users/MyName/.gem/ruby/2.1.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
  - SHELL PATH:
     - /usr/local/bin
     - /usr/local/bin
     - /usr/local/sbin
     - /usr/bin
     - /bin
     - /usr/sbin
     - /sbin
     - /usr/local/git/bin
     - /Users/MyName/.rvm/bin

Please give me advice to help me. Thank you!


Updated on Mar 7.

$ rvm list    
rvm rubies


# No rvm rubies installed yet. Try 'rvm help install'.

Just in case you would like to see Homebrew list,

$ brew list
autoconf    gmp4        libtool     openssl     readline
automake    libgpg-error    libyaml     pkg-config  ruby
cloog-ppl015    libksba     llvm        ppl011      ruby-build
gcc46       libmpc08    mpfr2       rbenv

2nd updated on Mar 7.

$ which ruby
/usr/local/bin/ruby

$ which jekyll
/usr/bin/jekyll

$ ruby --version
ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin12.0]

$ echo $PATH
/usr/local/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/Users/MyName/.rvm/bin

I remember that my mac had been installed Ruby 1.8.7 before I installed 2.1.1p76.

5
  • What do you get when you run rvm list?
    – nicksuch
    Mar 7, 2014 at 14:42
  • @SachinSingh Singh, I don't think this is a rails app. Jekyll's website documentation requires Ruby and RubyGems to install Jekyll.
    – Keita
    Mar 7, 2014 at 15:54
  • @nicksuch I added rvm list in my post, please check it out.
    – Keita
    Mar 7, 2014 at 15:56
  • Thanks for adding those, @user3391537! Could you also check which ruby, which jekyll, ruby --version, and echo $PATH ? It looks like you may have multiple versions of Ruby on your system (1.8 and 2.1.1), trying to figure out what points where.
    – nicksuch
    Mar 7, 2014 at 23:38
  • Thanks for your reply, @nicksuch! Added results of those commands. Before installing Ruby 2.1.1p76, 1.8.7 had been installed in my Mac. Hope you can figure out something. Thank you.
    – Keita
    Mar 8, 2014 at 6:18

2 Answers 2

9

It looks like you have multiple versions of Ruby on your system (1.8.7 and 2.1.1), which is very common, and part of the reason tools like rvm and rbenv were created. The issue is that when you did gem install jekyll (maybe with a sudo) and sudo gem install json, these seem to have ended up in different spots and aren't finding each other. The /usr/local/bin location is typically where Homebrew puts things (hence, you have ruby listed under brew list) and this is your Ruby 2.1.1 location. However, your jekyll installation is under the location of the Apple-installed Ruby 1.8.7.

Step 1: try gem uninstall jekyll, then gem install jekyll. This should fix your problems.

Step 2: If that doesn't work, try to use rbenv or rvm to select a different version of Ruby, then try Step 1 again.

For example, my installations are here (managed via rvm):

$ which jekyll
/Users/nicksuch/.rvm/gems/ruby-2.0.0-p247/bin/jekyll
$ which gem
/Users/nicksuch/.rvm/rubies/ruby-2.0.0-p247/bin/gem
$ which ruby
/Users/nicksuch/.rvm/rubies/ruby-2.0.0-p247/bin/ruby
3
  • 2
    Thank you so much @nicksuch Jekyll finally works!!! You're right. I uninstalled Jekyll, Ruby(from Homebrew), Rubygems, rvm once, then re-installed rvm with Ruby and Jekyll. After that, Ruby, gem, Jekyll have been stored at a same directory as like yours. jekyll new command working right now. I really appreciate. You're awesome @nicksuch!!!
    – Keita
    Mar 9, 2014 at 9:28
  • 1
    Excellent! Glad to help, happy Jekyll-ing!
    – nicksuch
    Mar 10, 2014 at 16:51
  • I'm having a similar issue, and tried your suggestion to no avail. I removed all installed ruby versions and reinstalled rvm and ruby from source. Then I ran bundle install and got the same error again. I checked all my paths as suggested above, and they all seem to be consistent. What should I do? Mar 3, 2015 at 3:21
4

In my case the Jekyll template suggested to use bundle utility as:

bundle exec jekyll build

The solution was to include json into Gemfile (which was already part of the sources):

diff --git a/Gemfile b/Gemfile
index 98b29af..b8537cf 100644
--- a/Gemfile
+++ b/Gemfile
@@ -1,7 +1,8 @@
 source "https://rubygems.org"

+gem "json"
 gem "jekyll", "~> 3.0"
 gem "jekyll-sitemap"

DETAILS

What lead me to the solution was the following fact:

  • command gem list json showed json gem installed;
  • but command bundle exec gem list json didn't show anything.

I also tried to run bundle exec gem install json - it didn't work. My best guess was that bundle sets up the environment for a single run based on Gemfile which is the only way to make set of dependencies persistent across each bundle exec ... executions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.