Finally Using Mechanical Pencil!

Another two weekends passed since publishing my own static site generator Mechanical Pencil. It Works On My Localâ„¢ but during deploy, it just throws up.

EEXIST: file already exists, symlink ...

The error is very vague and there's a lot of unknowns in play that just makes it very tedious to debug. Spending another 4+ hours on it, I managed to get it to deploy.

What's wrong to begin with?

In the first place, there's so many unknowns.

OpenShift uses a very old version of Node. The built-in for all cartridges is 0.6 and the official Node cartridge is 0.10. A lot of APIs are missing. I managed to backport the code to something 0.10 and even 0.6 can understand. Again, It Works On My Localâ„¢. Assuming that the code works fine, the environment must be broken. It could be anything, ranging from filesystem permissions to Node.js mishandling symlinks on older versions.

Exodus to Heroku for one morning

Getting annoyed, I actually signed up for Heroku. If it works there, then I'm throwing away OpenShift. That's unless Heroku is set up in the same way. Unfortunately, Heroku also spat the same error. So it's back to square one. However, reading through both docs and looking at the file system, I should have write access to where the repo is deployed to. Symlink creation shouldn't be a problem. So what is it really?

Bug hunting

So I concluded that it was neither environments' fault and I get to keep my OpenShift. The problem now is where to start. The error only tells me that the symlink operation failed because the script seems to think the link is already there. It only tells me which operation, Gobble's grab but no traces as to why it failed.


So I stepped back and started over, searching in Gobble for an "EEXIST". Boom! There was one related issue that dates back to September 2015. It's about the grab operation failing. Coincidentally, my deploy also fails on a grab operation. Both comments suggest that it works on Windows, not on a Linux. Without further ado, I restructured the code to not use grab and wallah! It deployed!

Where I am now

So if you're reading this now, my blog is powered by my own site generator, still on OpenShift, but using a custom Node.js cartridge that uses the latest version of Node. I now have full control of the generation process and can even write in ES6. There's more to come in the design front. The minimalist look is nice, but the blue is just annoying to look at.

node.js site generator diy

© Joseph Descalzota