找不到幻影

Ser*_*eev 30 ruby ubuntu phantomjs

尝试在Ubuntu上使用ruby中的phantomjs时出现以下错误:

 Failure/Error: visit root_path
 Cliver::Dependency::NotFound:
   Could not find an executable ["phantomjs"] on your path.
 # ./spec/features/search_spec.rb:17:in `block (2 levels) in <top (required)>'
 # ./spec/support/vcr.rb:23:in `block (3 levels) in <top (required)>'
 # ./spec/support/vcr.rb:23:in `block (2 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud)

phantomjs在当地建造并添加到PATH.如何让红宝石找到幻影?

Mat*_*hew 31

你也可以

$ sudo apt-get install phantomjs                               
Run Code Online (Sandbox Code Playgroud)

这应该会自动将phantomj添加到您的路径中,并执行其正确运行所需的一切.这对我有用.

  • `E: 无法找到包 phantomjs` (2认同)

pja*_*mer 31

而不是在本地构建,在Mac上使用自制软件,brew install phantomjs然后所有路径将链接.我自己有这个错误,你将免费获得链接,并有能力轻松更新.

  • 正如谷歌已经证明的那样,这是与phantomjs和那个错误有关的最佳结果.3 upvotes也证明你应该修复这个问题,因为它不是特定于操作系统的. (4认同)
  • 你不能再只使用“brew install”,它现在是一个木桶,所以“brew cask install phantomjs” (2认同)

Aam*_*mir 16

对于Mac Os El Capitan使用下面的命令:

npm install -g phantomjs
Run Code Online (Sandbox Code Playgroud)

以上命令仅在安装时才有效npm,用于安装npm:

 brew install npm
Run Code Online (Sandbox Code Playgroud)


gay*_*vat 10

添加到Gemfile

gem 'phantomjs', :require => 'phantomjs/poltergeist'
Run Code Online (Sandbox Code Playgroud)

或者将代码放在spec_helper.rb下面

require 'phantomjs' 
Capybara.register_driver :poltergeist do |app|
    Capybara::Poltergeist::Driver.new(app, :phantomjs => Phantomjs.path)
end
Run Code Online (Sandbox Code Playgroud)

https://github.com/colszowka/phantomjs-gem


Ser*_*eev 3

显然,解决方案不仅是将 phantomjs 添加到 PATH,还要创建链接:

sudo ln -s /home/myuser/phantomjs/bin/phantomjs /usr/bin/phantomjs
sudo ln -s /home/myuser/phantomjs/bin/phantomjs /usr/local/bin/phantomjs
sudo ln -s /home/myuser/phantomjs/bin/phantomjs /usr/local/share/phantomjs
Run Code Online (Sandbox Code Playgroud)

调整/home/myuser/phantomjs/bin/phantomjs路径以匹配计算机上 phantomjs 二进制文件的路径。