KISS πŸ‡ΊπŸ‡¦

Stop the war!

Stop the war in Ukraine! Fuck putin!

More information is at: https://war.ukraine.ua/.

There is a fund to support the Ukrainian Army: https://savelife.in.ua/en/donate/, and there is a special bank account that accepts funds in multiple currencies: https://bank.gov.ua/en/about/support-the-armed-forces. I donated to them. Please donate if you can!

Killer putin

Killer putin. Source: politico.eu.

Arrested putin

"It hasn't happened yet, but it will happen sooner or later. Beautiful photo, isn't it?" Source: twitter.

Issues with pygments.rb in Arch Linux

| comments

I’ve had bad luck with ruby stuff; once in a while, something in my setup for Octopress breaks and I can’t build this blog. For example, this time I had issues with pygments.rb package, which provides colorizing for source code blocks.

Updated on 2013-04-28: I’m lucky enough to have had this issue not only in Arch Linux, but on OS X as well (after all, cross-platform tools tend to have the same cross-platform issues, right?). The latest pygments.rb-0.5.0 is still the same.

rake generate showed this:

1
2
3
4
5
6
7
8
9
10
11
12
13
/home/user/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/pygments.rb-0.2.13/lib/pygments/ffi.rb:7:in `start': wrong number of arguments (2 for 1) (ArgumentError)
        from /home/user/src/octopress/plugins/pygments_code.rb:5:in `<top (required)>'
        from /home/user/src/octopress/plugins/code_block.rb:44:in `require'
        from /home/user/src/octopress/plugins/code_block.rb:44:in `<top (required)>'
        from /home/user/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/site.rb:76:in `require'
        from /home/user/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/site.rb:76:in `block in setup'
        from /home/user/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/site.rb:75:in `each'
        from /home/user/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/site.rb:75:in `setup'
        from /home/user/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/lib/jekyll/site.rb:30:in `initialize'
        from /home/user/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/bin/jekyll:224:in `new'
        from /home/user/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/jekyll-0.11.2/bin/jekyll:224:in `<top (required)>'
        from /home/user/.rbenv/versions/1.9.3-p194/bin/jekyll:23:in `load'
        from /home/user/.rbenv/versions/1.9.3-p194/bin/jekyll:23:in `<main>'

Running bundle update didn’t help. I found out the newest version of pygments.rb was 0.4.2. How to install it? Running gem install -V pygments.rb did the trick. But octopress didn’t use the update. To fix that, edit the Gemfile:

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

, then run bundle update. The issue remains though:

1
2
3
4
/home/user/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/pygments.rb-0.4.2/lib/pygments/popen.rb:22:in `start': wrong number of arguments (2 for 1) (ArgumentError)
        from /home/user/src/octopress/plugins/pygments_code.rb:5:in `<top (required)>'
        from /home/user/src/octopress/plugins/code_block.rb:44:in `require'
        from /home/user/src/octopress/plugins/code_block.rb:44:in `<top (required)>'

Long story short, I found somewhere this fix. Open the file where the error pops up (/home/user/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/pygments.rb-0.4.2/lib/pygments/popen.rb), comment line 22, and these lines:

1
2
def start(pygments_path = nil, opts = {})
  pygments_path ||= File.expand_path('../../../vendor/pygments-main/', __FILE__)

That’s not the end, this time another error prevents the build:

1
2
3
4
5
6
7
8
/home/user/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/pygments.rb-0.4.2/lib/pygments/popen.rb:253:in `rescue in mentos': EPIPE (MentosError)
        from /home/user/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/pygments.rb-0.4.2/lib/pygments/popen.rb:205:in `mentos'
        from /home/user/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/pygments.rb-0.4.2/lib/pygments/popen.rb:194:in `highlight'
        from /home/user/src/octopress/plugins/pygments_code.rb:26:in `pygments'
        from /home/user/src/octopress/plugins/pygments_code.rb:16:in `highlight'
        from /home/user/src/octopress/plugins/backtick_code_block.rb:37:in `block in render_code_block'
        from /home/user/src/octopress/plugins/backtick_code_block.rb:13:in `gsub'
        from /home/user/src/octopress/plugins/backtick_code_block.rb:13:in `render_code_block'

Open this file /home/user/.rbenv/versions/1.9.3-p194/lib/ruby/gems/1.9.1/gems/pygments.rb-0.4.2/lib/pygments/mentos.py and in the first line replace #!/usr/bin/env python with #!/usr/bin/env python2. This is required in Arch Linux, because the python command points to Python 3. Phew, it works again!

A helpful link I’ve come across: http://stackoverflow.com/questions/13899848/octopress-include-code-crash.

Comments