Rails 水豚 Cliver::Dependency::NotFound 在生产中
我正在尝试在 Rails 应用程序中计划的 Sidekiq 任务中运行 Capybara。它在本地工作(正如它的设计目的),但是在部署时我遇到了 Cliver::Dependency::NotFound
错误。
您对我如何让它发挥作用有什么想法吗?
require 'capybara'
require 'capybara/cuprite'
Capybara.javascript_driver = :cuprite
Capybara.enable_aria_label = true
Capybara.register_driver(:cuprite) do |app|
Capybara::Cuprite::Driver.new(app, {
js_errors: false,
headless: true,
timeout: 500,
slowmo: 0.05
})
end
@session = Capybara::Session.new(:cuprite)
@session.visit('www.some-url-goes-here.com')
这是访问任何 URL 时触发的错误。
/app/vendor/bundle/ruby/3.0.0/gems/ferrum-0.11/lib/ferrum/browser/command.rb:32:in `initialize': Could not find an executable for the browser. Try to make it available on the PATH or set environment variable for example BROWSER_PATH="/usr/bin/chrome" (Cliver::Dependency::NotFound)
I'm attempting to run Capybara in production in a scheduled Sidekiq task in my Rails app. It works locally (as it was designed to), but when deployed I run into a Cliver::Dependency::NotFound
error.
Do you have any ideas on how I can get this working?
require 'capybara'
require 'capybara/cuprite'
Capybara.javascript_driver = :cuprite
Capybara.enable_aria_label = true
Capybara.register_driver(:cuprite) do |app|
Capybara::Cuprite::Driver.new(app, {
js_errors: false,
headless: true,
timeout: 500,
slowmo: 0.05
})
end
@session = Capybara::Session.new(:cuprite)
@session.visit('www.some-url-goes-here.com')
This is the error that's triggered when visiting any URL.
/app/vendor/bundle/ruby/3.0.0/gems/ferrum-0.11/lib/ferrum/browser/command.rb:32:in `initialize': Could not find an executable for the browser. Try to make it available on the PATH or set environment variable for example BROWSER_PATH="/usr/bin/chrome" (Cliver::Dependency::NotFound)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要告诉 Cuprite Chrome 浏览器二进制文件在生产计算机上的位置。它搜索常见位置,因此在您的生产环境中,它要么未安装,要么安装在非默认位置。
You need to tell Cuprite where the Chrome browser binary is located on your production machine. It searches common locations, so in your production env it’s either not installed or installed in a non-default location.