我关注了 Railscasts 中关于使用 Redcarpet、Albino 和 Pygments 向应用程序添加代码突出显示的内容。它在开发中按预期工作。但是,在我的测试生产服务器上,我收到以下错误:
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'
错误来自第markdown()
16 行的帮助程序。帮助程序代码是:
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(pre.text.rstrip, pre[:lang])
end
doc.to_s
end
问题出在给 Albino 的电话上。我不知道如何解决这个问题。似乎 Albino 无法产生该pygmentize
过程。当我which pygmentize
在 Terminal.app 中运行时,我看到/usr/local/bin/pygmentize
. /usr/local/bin
跑步时出现在我的路径中echo $PATH
。测试生产服务器是 OS X 10.7 服务器上的 Apache/Phusion Passenger。
这是怎么回事,我该如何解决这个posix_spawnp
错误?