Jekyll - command not found
If you are using MacOS, from the Troubleshooting guide:
Jekyll & Mac OS X 10.11Permalink
With the introduction of System Integrity Protection, several directories that were previously writable are now considered system locations and are no longer available. Given these changes, there are a couple of simple ways to get up and running. One option is to change the location where the gem will be installed (again, using sudo only if necessary):
$ gem install -n /usr/local/bin jekyll
For others coming here with the following set up:
OS X + brewed install of ruby + (possibly) zsh
I figured the problem is that after installing jekyll as per their instructions, gem installs the jekyll gem in the brew cellar, not where the OS usually expects it (somehwere in a gem directory for ruby).
So, all that was needed here was to find out where the brew install of ruby installs gems, locate the jekyll binary, and create a symbolic link to it in /usr/bin
.
Here is are the steps I took to fix it:
-
Type
gem env
and look for GEM PATHS. For me it was:/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1
. -
Make sure you can see the
jekyll
binary in the directory from 1 above and copy its path (if you can't, search any other paths listed in GEM PATHS for it). For me it was:/usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/bin/jekyll
-
Use the path from step 2 above to create a symlink to
/usr/bin/jekyll
. I did it by typing this (you might needsudo
to create the symlink):cd /usr/bin && ln -s /usr/local/Cellar/ruby/1.9.3-p194/lib/ruby/gems/1.9.1/gems/jekyll-1.4.3/bin/jekyll jekyll
Now all should be merry if you type jekyll
.
The easiest method of doing this is to use RVM. It manages Ruby and all its gems for you and it's easy to use. See this link for using it.
If you did not want to use that you will need to modify your PATH variables so it can find your gems. I have found this to be tedious and reverted to RVM, but here are the general steps.
You will need to find out where your gems are getting installed. If you did gem install ...
the gems will be in ~/.gem/ruby/1.8/gems/bin
, if you used sudo gem install ...
the gems will be somewhere in /System/Library/Frameworks/Ruby.framework/Versions/1.8/Resources
You have to add this path to your PATH variable. Easiest way to do this is by running :
echo 'PATH=$PATH:above/path/to/gems' >> ~/.bash_profile
If you are using RBENV instead of RVM you simply need to run rehash
in the command line after installing jekyll:
rbenv rehash