错误的 wkhtmltopdf 路径:捆绑器:找不到命令:哪个

Bad wkhtmltopdf's path: bundler: command not found: which

我在 Windows 上的 Rails 中使用 wkhtmltopdf gem,但它不起作用。我收到此错误: “错误的 wkhtmltopdf 路径:捆绑器:找不到命令:哪个”。 它适用于 exe,但我不想使用 exe_path,我只想使用 gem。 这是我的 wkhtmltopdf 配置文件:

# WickedPDF Global Configuration
#
# Use this to set up shared configuration options for your entire application.
# Any of the configuration options shown here can also be applied to single
# models by passing arguments to the `render :pdf` call.
#
# To learn more, check out the README:
#
# https://github.com/mileszs/wicked_pdf/blob/master/README.md

WickedPdf.config = {
  # Path to the wkhtmltopdf executable: This usually isn't needed if using
  # one of the wkhtmltopdf-binary family of gems.
  # exe_path: 'C:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe'
  
}

我也在用 gem 'wicked_pdf' gem 'wkhtmltopdf-binary'

wkhtmltopdf gem 似乎不支持 Windows 操作系统。我在源代码中找到了这个:

suffix = case RbConfig::CONFIG['host_os']
when /linux/
  (RbConfig::CONFIG['host_cpu'] == 'x86_64') ? 'linux_amd64' : 'linux_x86'
when /darwin/
  'darwin_x86'
else
  raise "Invalid platform. Must be running on linux or intel-based Mac OS."
end

另一个提示是您收到的事实:command not found: whichwhich 是用于识别可执行文件位置的 Unix 命令,不适用于 Windows。抱歉

这对我有用

exe_path: 'C://Program Files/wkhtmltopdf/bin/wkhtmltopdf.exe'