Prab's Code Blog

Because talk is cheap, show me the code!

Octopress Syntax Highlighting Issue on Arch Linux

If you run Arch Linux and are trying to run rake generate on a Octopress blog, with a post that uses some code and syntax highlighting markdown over it; you will probably see this error:

/plugins/pygments_code.rb:27:in `rescue in pygments': Pygments can't parse unknown language: ruby. (RuntimeError)

This happens because Arch uses python3 as default python, while the world hasn’t yet made up their mind to switch. The Pygments gem that Octopress uses, uses python2 syntax which Arch’s python3 doesn’t undertand fully and hence raises an error. To fix this, just open this file:

1
~/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/pygments.rb-0.3.4/lib/pygments/mentos.py

Use your own version, instead of 2.1.0 that I am using. Change the first line:

mentos.py
1
#!/usr/bin/env python 

to

mentos.py
1
#!/usr/bin/env python2 

After this, your rake generate should succeed. Oh, and yes, this file path is for rbenv. If you use rvm figure out your own path using the command find ~/ -name mentos.py.

Comments