18

I installed jekyll, but surprisingly somehow osx doesn't recognise its installed.

$ sudo gem install jekyll
Password:
Successfully installed jekyll-1.2.1
Parsing documentation for jekyll-1.2.1
Done installing documentation for jekyll after 1 seconds
1 gem installed

$ jekyll
-bash: jekyll: command not found

gem environment ( - INSTALLATION DIRECTORY: /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0 )

$ cd /usr/local/Cellar/ruby/2.0.0-p247/lib/ruby/gems/2.0.0/gems/

enter image description here

echo $PATH

/usr/local/bin:/usr/local/sbin:~/bin:/usr/local/bin:/usr/local/sbin:~/bin:/Users/TheSpiritMolecule/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Users/TheSpiritMolecule/.rvm/bin
aegyed
  • 1,320
  • 3
  • 20
  • 39
  • a friend found the solution for my case, regarding issues with OS X freaking Captain: http://stackoverflow.com/a/33059347/274502 – cregox Dec 28 '15 at 10:12

3 Answers3

20

I have rbenv installed and the step I missed was to do an rbenv rehash after gem install jekyll. The rehash creates a link in ~/.rbenv/shims which is in included in $PATH.

pbatey
  • 1,234
  • 13
  • 13
  • Sweet! For reference the rbenv docs say "Run this command (rehash) after you install a new version of Ruby, or install a gem that provides commands" – Sam Eaton Oct 27 '15 at 18:33
  • I did rehash. Is there any way to know if it has worked? Can I see where the Jekyll is installed? I can not find it with *which* command. – Harshal Apr 01 '17 at 13:28
10

Okay I had to check what exatly does the $PATH means, and for what it is.

The problem was simple, somehow my ruby installion directory wasnt in my $path variable.

Useful links: Mac OS X: Set / Change $PATH Variable

Okay so here is the thing how I solved it:

echo "$PATH"
gem uninstall jekyll
find / -name jekyll (to delete if there is any leftovers somewhere )
gem environment ( get EXECUTABLE DIRECTORY path )
nano $HOME/.bash_profile ( go to the end of document and insert a new line )
export PATH="/usr/local/Cellar/ruby/2.0.0-p247/bin:$PATH"

you can do this on a templorary way by just writing it in terminal and not saving it in your .bash_profile

aegyed
  • 1,320
  • 3
  • 20
  • 39
3

Following steps solved my problem

gem uninstall jekyll
sudo gem install jekyll

Open ~/.bash_profile and add this code in the last line,

export PATH=$PATH:/usr/local/lib/ruby/gems/1.9.1/gems/jekyll-2.5.2/bin

Save and close the .bash_profile

Close and reopen the mac terminal, try running jekyll now, it should work

Community
  • 1
  • 1
Ashwin Aggarwal
  • 649
  • 8
  • 21