I came up against an error using Octopress, when I ran rake generate
I got the following error:
1 2 3 |
|
Edit Following a comment from Josh below, I’ve tried his suggested fix of upgrading the version instead – delete your Gemfile.lock and edit the version of rake specified in your Gemfile to 10.1. Job done! It’s working fine as far as I can tell. /Edit
Not really understanding ruby, bundler, gemfiles et al, I hit the g**gles and figured out that this was probably because I built another unrelated project which had specified a higher version of rake in it’s gemfile, and by the magic of gems, the new version was installed. The local (to octopress) gemfile.lock specifies the lower version, and refuses to work with the higher version. (As far as I can figure out, Ruby and Gem versioning is the new, DLL-hell).
Work around
The work around mentioned in the error message (bundle exec) is to invoke rake as follows:
1
|
|
This works, I gather it causes bundler to dynamically find the version specified in the Gemfile.lock and use that for this one invocation, but it’s bit of a kludge.
You could paint-over-the-rust by adding a bash alias or something to reduce the keystrokes, but a slightly more fixy fix is to run the following (found in this blog post and it’s comments)
1
|
|
This gets all the gems, in the versions specified in your gemfile.lock, and puts them into a bin directory local to the project. From then onwards, for that folder, you don’t need to care and can just invoke rake as normal.
rbenv plugin needed
This didn’t actually work for me, probably because I use rbenv instead of rvm, so some more searching turned up a plugin, rbenv-binstubs that sorted it out: (it was super easy to install, just clone the github repo straight into a rbenv plugins folder).
add bin to .gitignore
Finally, add the following line to your .gitignore so that the bin folder doesn’t get checked in.
1
|
|