【问题标题】:PDFKit::NoExecutableError on Ubuntu ServerUbuntu 服务器上的 PDFKit::NoExecutableError
【发布时间】:2017-07-06 13:52:05
【问题描述】:

在我的 Rails 环境日志文件中

PDFKit::NoExecutableError (No wkhtmltopdf executable found at `/` is not writable. Bundler will use `/tmp/bundler/home/unknown' as your home directory temporarily. /home/ubuntu/rails-app/shared/bundle/ruby/2.3.0/bin/wkhtmltopdf

请安装 wkhtmltopdf - https://github.com/pdfkit/PDFKit/wiki/Installing-WKHTMLTOPDF): pdfkit (0.8.2) lib/pdfkit/pdfkit.rb:32:in initialize' pdfkit (0.8.2) lib/pdfkit/middleware.rb:21:innew' pdfkit (0.8.2) lib/pdfkit/middleware.rb:21:in `call'

我按照apt-get 的指示尝试安装,但错误仍然存​​在。

ubuntu@server:~$ which wkhtmltopdf

/home/ubuntu/.rbenv/shims/wkhtmltopdf

ubuntu@server:~$ wkhtmltopdf --version

wkhtmltopdf 0.12.3 (with patched qt)

【问题讨论】:

    标签: ruby-on-rails ruby wkhtmltopdf pdfkit


    【解决方案1】:

    你试过了吗

    并创建新文件 config/initializers/pdfkit.rb

    PDFKit.configure do |config|
      config.wkhtmltopdf = '/home/ubuntu/.rbenv/shims/wkhtmltopdf'
    end
    

    【讨论】:

    • 我怎么知道路径?捆绑显示 wkhtmltopdf 对吗? config.wkhtmltopdf = '/home/ubuntu/rails-app/shared/bundle/ruby/2.3.0/gems/wkhtmltopdf-binary-0.12.3.1' 仍然不起作用
    • 我使用了基于which wkhtmltopdf on the root directory的wkhtmltopdf路径然后出现了这个错误RuntimeError (command failed (exitstatus=1): /usr/bin/wkhtmltopdf --quiet --page-size Letter --margin-top 0.75in --margin-right 0.75in --margin-bottom 0.75in --margin-left 0.75in --encoding UTF-8 --print-media-type - -): pdfkit (0.8.2) lib/pdfkit/pdfkit.rb:71:in `to_pdf'
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-22
    • 2017-10-28
    • 2012-01-27
    • 2015-03-15
    • 2014-05-06
    相关资源
    最近更新 更多