开发者

Rails 3.1 error related to posix_spawnp when using the Albino gem and Redcarpet

I followed the Railscasts episode about adding code highlighting to an app using Redcarpet, Albino, and Pygments. It works as expected in development. On my test production server, however, I receive the following error:

ActionView::Template::Error (No such file or directory - posix_spawnp):
13:         <div class="small_meta">
14:             Posted on <%= @article.created_at %> by <%= @article.user.full_name %>. Topics: <%= @article.topic_list %>
15:         </div>
16:         <%= markdown(@article.body) %>
17:     </div>
18: 
19: <% else %>
app/helpers/application_helper.rb:19:in `block in syntax_highlighter'
app/helpers/application_helper.rb:18:in `syntax_highlighter'
app/helpers/application_helper.rb:13:in `markdown'
app/views/home/index.html.erb:16:in `_app_views_home_index_html_erb___3638324493742336500_70112578553660'

The error comes from the markdown() helper on line 16. The helper code is:

def markdown(text)
  options = [:hard_wrap, :filter_html, :autolink, :no_intraemphasis, :fenced_code, :gh_blockcode]
  syntax_highlighter(Redcarpet.new(text, *options).to_html).html_safe
end

def syntax_highlighter(html)
    doc = Nokogiri::HTML(html)
    doc.search("//pre[@lang]").each do |pre|
      pre.replace Albino.colorize(pr开发者_开发问答e.text.rstrip, pre[:lang])
    end
    doc.to_s
end

The problem is from the call to Albino. I'm at a loss as to how to fix this problem. It appears that Albino is unable to spawn the pygmentize process. When I run which pygmentize in Terminal.app, I see /usr/local/bin/pygmentize. /usr/local/bin appears in my paths when I run echo $PATH. The test production server is Apache/Phusion Passenger on OS X 10.7 Server.

What is going on here and how can I fix the posix_spawnp error?


I got the same error and fixed it by installing pygmentize. Make sure that you installed pygmentize into the correct Python interpreter. I'm running OS X 10.7 and I have 4 different python interpreters! You can find out which python you are actively running by typing

python --version

Also check read/write permissions on all pertinent directories, i.e. '/Library/Python/2.7/site-packages'

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜