Ruby 找不到幻影
尝试从ruby on Ubuntu使用phantomjs时出现以下错误:Ruby 找不到幻影,ruby,ubuntu,phantomjs,Ruby,Ubuntu,Phantomjs,尝试从ruby on Ubuntu使用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)>' # ./
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)>'
故障/错误:访问根路径
Cliver::Dependency::NotFound:
在您的路径上找不到可执行文件[“phantomjs”]。
#./spec/features/search_spec.rb:17:in'block(2层)in'
#./spec/support/vcr.rb:23:in'block(3层)in'
#./spec/support/vcr.rb:23:in'block(2层)in'
phantomjs在本地构建并添加到PATH。如何使ruby查找phantomjs?显然,解决方案不仅是将phantomjs添加到路径中,而且还创建链接:
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
调整/home/myuser/phantomjs/bin/phantomjs
路径以匹配机器上phantomjs二进制文件的路径。您也可以这样做
$ sudo apt-get install phantomjs
这将自动将phantomjs添加到您的路径中,并执行所有其他必要的操作以使其正确运行。这对我很有用。不要在本地构建,而是在mac上使用自制的
brew install phantomjs
,所有路径都将在之后链接。我自己也有这个错误,你可以免费获得链接,并且可以轻松更新 添加到文件
gem 'phantomjs', :require => 'phantomjs/poltergeist'
或者将下面的代码放入spec_helper.rb
require 'phantomjs'
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, :phantomjs => Phantomjs.path)
end
对于
Mac Os El Capitan
使用以下命令:
npm install -g phantomjs
上述命令仅在安装了npm
时有效,用于安装npm
:
brew install npm
其他可能的解决方案是向文件添加可执行权限:
# download phantomjs
$ curl --output /home/user/.rvm/bin/phantomjs https://s3.amazonaws.com/circle-downloads/phantomjs-2.1.1
# set rights
$ chmod +x /home/user/.rvm/bin/phantomjs
# check
$ which phantomjs
/home/user/.rvm/bin/phantomjs
而且,不建议使用官方Ubuntu repos的phantomjs
:
不要使用官方Ubuntu存储库中的phantomjs,因为它
和恶鬼相处不好
如问题中所述,这是关于Ubuntu上的phantomjs,而不是Mac。正如谷歌所证明的,这是与phantomjs和该错误有关的所有结果的最高值。3次投票也证明了你应该解决这个问题,因为它不是特定于操作系统的。你不能再只使用
brew安装
,它现在是一个木桶,所以请使用brew木桶安装phantomjs
我的问题是apt get安装了一个旧版本(1.9.0),而我需要2.0.0E:找不到包phantomjs