Richard
Richard

Reputation: 65510

How to set up Jekyll cleanly on an existing OSX system?

I am an inexperienced Ruby user and I want to start using a Jekyll theme. I am working on OSX El Capitan and there may be old Ruby tools lying around on this machine.

I have downloaded this theme and installed it to a local directory. Next I tried to run bundle and saw this error:

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

Full error output here: http://pastebin.com/mv2r91xU

Next, I tried running gem install nokogiri -v '1.5.9', but I saw this error:

-bash: /usr/local/bin/gem: No such file or directory

I don't know how to install gem, and I suspect I'm not using the "right" Ruby or bundler. Where should these tools be? What do I need to check I've deleted to start cleanly from scratch? (e.g. I tried setting up rbenv, but I think it may have failed because I already had RVM installed)

These are the paths to ruby and bundler:

$ which ruby
/usr/bin/ruby
$ which bundle
/usr/local/bin/bundle

Upvotes: 0

Views: 215

Answers (1)

Ross
Ross

Reputation: 2851

I'd suggest using rbenv to manage your Ruby versions, and ignoring the default system-wide version. You mention you tried, but I think it'd be worth giving it another go.

rbenv is best installed through Homebrew, install it with the following:

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Then install rbenv with Homebrew:

$ brew install rbenv ruby-build

You can then set and switch between Ruby versions (giving you clean environments) anytime without changing the default system version:

$ rbenv install 2.3.1
$ rbenv global 2.3.1
$ ruby -v

Once Ruby is sorted, you should be able to install and run the latest Jekyll through the Bundler:

$ gem install jekyll
$ jekyll new my-awesome-site
$ cd my-awesome-site
$ bundle install
$ bundle exec jekyll serve

Running Jekyll through Bundler rather than directly is the new suggested method.

Upvotes: 2

Related Questions