Damn You, Octopress!

Comments

Octopress work reasonably well - until something happens. Say, for example, you are on OS X and upgrade your python to 2.7.3. Everything stops working, and you’ll never be able to fix it again. A ruby application that relies on python - what could possibly go wrong?

Could not find platform independent libraries

After upgrading python, suddenly running rake generate resulted in this error:

1
2
3
4
5
6
7
8
9
10
rake generate
## Generating Site with Jekyll
unchanged sass/screen.scss
/Users/ME/.rvm/gems/ruby-1.9.3-p194/gems/maruku-0.6.0/lib/maruku/input/parse_doc.rb:22:in `<top (required)>': iconv will be deprecated in the future, use String#encode instead.
Configuration from /Users/ME/work/octopress/_config.yml
Building site: source -> public
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
ImportError: No module named site

Oh. Well, let’s just do what it says, shall we? I open ~/.bash_profile with nano ~/.bash_profile and add

1
export PYTHONHOME=/usr/bin/python

then restart Terminal. That solves that particular issue.

sh: - : invalid option

But now I am getting another error:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
rake generate
## Generating Site with Jekyll
unchanged sass/screen.scss
/Users/ME/.rvm/gems/ruby-1.9.3-p194/gems/maruku-0.6.0/lib/maruku/input/parse_doc.rb:22:in `<top (required)>': iconv will be deprecated in the future, use String#encode instead.
Configuration from /Users/ME/work/octopress/_config.yml
Building site: source -> public
ImportError: No module named site
sh: - : invalid option
Usage:  sh [GNU long option] [option] ...
  sh [GNU long option] [option] script-file ...
GNU long options:
  --debug
  --debugger
  --dump-po-strings
  --dump-strings
  --help
  --init-file
# etc

The issue seems to be pygment, the module that does syntax highlighting. It is written in python, and run from inside one of the gems. I tried a few different things, but in the end the most successful was creating a file in the plugins directory, plugins/octopress_fix.rb, with instructions to run the older version of python

1
2
require 'rubypython'
RubyPython.configure :python_exe => 'python2.6'

`block in ffi_lib’: Could not open library ‘lib.dylib’

The latest error message is now

1
2
3
4
5
6
7
8
9
10
rake generate
## Generating Site with Jekyll
unchanged sass/screen.scss
/Users/ME/.rvm/gems/ruby-1.9.3-p194/gems/maruku-0.6.0/lib/maruku/input/parse_doc.rb:22:in `<top (required)>': iconv will be deprecated in the future, use String#encode instead.
Configuration from /Users/ME/work/octopress/_config.yml
Building site: source -> public
'import site' failed; use -v for traceback
'import site' failed; use -v for traceback
'import site' failed; use -v for traceback
/Users/ME/.rvm/gems/ruby-1.9.3-p194/gems/ffi-1.0.11/lib/ffi/library.rb:121:in `block in ffi_lib': Could not open library 'lib.dylib': dlopen(lib.dylib, 9): image not found (LoadError)

Google takes me to this pygments issue on github, where it is suggested I upgrade the version of pygments in octopress/Gemfile

1
  gem 'pygments.rb', '~> 0.3.2'

blankslate.rb warning: undefining `object_id’ may cause serious problems

The error is now

1
2
3
4
5
6
7
rake generate
## Generating Site with Jekyll
unchanged sass/screen.scss
Configuration from /Users/ME/work/octopress/_config.yml
/Users/ME/.rvm/gems/ruby-1.9.3-p194/gems/blankslate-3.1.2/lib/blankslate.rb:51: warning: undefining `object_id' may cause serious problems
Building site: source -> public
/Users/ME/.rvm/gems/ruby-1.9.3-p194/gems/pygments.rb-0.3.2/lib/pygments/popen.rb:351:in `rescue in get_header': Failed to get header. (MentosError)

pygments.rb has meanwhile been updated to 0.3.3, so I try

1
gem update pygments

then bump the number up in the Gemfile, but no improvement.

Pygments.rb doesn’t like Python 2.7.3

In the end I had to rever Python version by amending the Python version of from 2.7.3 to 2.6 in the path in my ~/.bash_profile file

1
....System/Library/Frameworks/Python.framework/Versions/2.6/bin:$PATH

Ok that works - still get the “blankslate.rb warning: undefining `object_id’ may cause serious problems” line but it generates site. But I don’t like it at all, it seems brittle. Granted, I can’t blame Octopress for Ruby and Python not talking to each other, but still.

Comments