Errno::ENOENT: No Such File or Directory - Jekyll ~ Octopress and El Capitan


Since I started blogging again a while ago I decided to forgo the usual Wordpressroute and try this thing called Octopress. I have to say, I am extremely delighted, and the fact that I can host it all on Github for free, well that is just the Siracha on my Chipotle.

Octopress also makes previewing your site and deploying it to Github super simple. Want to preview the site locally and auto generate the appropriate files when things change, well, just run:

$ rake preview

Want to generate and deploy your site to Github. After some simple config, it is as simple as:

$ rake generate && rake deploy

This all worked great, and makes blogging a joy. But as you might have noticed, I said workedand not work. The reason is that, after upgrading to Mac OSX El Capitan, commands like rake previewand rake watchfails with the following error:

$rake previewStarting to watch source with Jekyll and Compass. Starting Rack on port 4000rake aborted!Errno::ENOENT: No such file or directory - compass/Users/user/git/octopress/Rakefile:85:in spawn/Users/user/git/octopress/Rakefile:85:in block in <top (required)>Tasks: TOP => preview

I went on a search for the answer or to confirm that this is actually a bug on El Capitan. After some time I landed on this Octopress issue on Github. So there it is, confirmed. Now what though?

First thing I did was to check my Ruby version.

$ ruby --versionruby 2.0.0p645 (2015-04-13 revision 50299) [universal.x86_64-darwin15]

Having a look over on the Ruby site I noticed that the latest version of the language is in fact version 2.2.3. After multiple failed attempts at upgrading with HomebrewI decided to have a look at rbenv. From the repo:

Use rbenv to pick a Ruby version for your application and guarantee that your development environment matches production.

This is essentially the same as virtualenv, which I use daily for the Django projects I work on. Essentially it creates and isolated environment for your project in which you control the version of Ruby etc. Installing rbenv is a dead simple process, just run the following(assuming you have Homebrew installed):

$ brew update$ brew install rbenv ruby-build

You can see that apart from rbenv itself, it also installs ruby-buildas a plugin to rbenv. This is what is going to allow us to install various versions of Ruby on the same machine, and then use rbenv, to specify the version we want to use for our current project.

Once the above completes, go ahead and install the latest Ruby version using:

$ rbenv install 2.2.3

Next we are going to specify that we want to use this version for our Octopress blog. To do so, head into the root of your Octopress blog folder and run:

$ rbenv local 2.2.3

If you now check your Ruby version, you should see the following:

$ ruby --versionruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin15]

Nice! But did it fix anything? Well, first things first. Because we have created this isolated virtual environment if you will, we need to install Octopress' dependencies again so, go ahead and run:

$ gem install bundler# When the above completes$ rbenv rehash$ bundle install

Once bundler has installed all the things, we can test whether the raketasks work.

$ rake previewStarting to watch source with Jekyll and Compass. Starting Rack on port 4000[2015-10-16 12:04:24] INFO WEBrick 1.3.1[2015-10-16 12:04:24] INFO ruby 2.2.3 (2015-08-18) [x86_64-darwin15][2015-10-16 12:04:24] INFO WEBrick::HTTPServer#start: pid=13775 port=4000Configuration file: /Users/espressive/repos/schalk-neethling/_config.yml>>> Compass is watching for changes. Press Ctrl-C to Stop. Source: source Destination: public Generating... write public/stylesheets/screen.css ... And It Works!

This leads me to believe that there is a bug in the Ruby version that comes with El Capitan and the posix-spawndependency that Octopress uses in the rake preview, rake watchcode blocks.

Hopefully this is soon resolved but, working with virtual environments per project and being able to control the versions of the dependencies you use is a much better way of working anyhow so, we need not hold our breath.