专案可在一台电脑上运作,但无法在其他电脑上运作

时间:2018-10-26 23:51:03

标签: ruby rubygems bundler

我的红宝石项目在其中一部Macbook上运行正常,但在另一本上却出现此错误:

Traceback (most recent call last):
    13: from bin/audiobook-now:5:in `<main>'
    12: from /Users/TuzsNewMacBook/Development/code/audiobook-now-cli/lib/cli.rb:50:in `run'
    11: from /Users/TuzsNewMacBook/Development/code/audiobook-now-cli/lib/cli.rb:7:in `get_books_from'
    10: from /Users/TuzsNewMacBook/Development/code/audiobook-now-cli/lib/scraper.rb:7:in `scrape_book_list'
     9: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/capybara-2.18.0/lib/capybara/session.rb:274:in `visit'
     8: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/poltergeist-1.18.1/lib/capybara/poltergeist/driver.rb:100:in `visit'
     7: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/poltergeist-1.18.1/lib/capybara/poltergeist/driver.rb:27:in `browser'
     6: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/poltergeist-1.18.1/lib/capybara/poltergeist/driver.rb:47:in `client'
     5: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/poltergeist-1.18.1/lib/capybara/poltergeist/client.rb:16:in `start'
     4: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/poltergeist-1.18.1/lib/capybara/poltergeist/client.rb:16:in `new'
     3: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/poltergeist-1.18.1/lib/capybara/poltergeist/client.rb:53:in `initialize'
     2: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/cliver-0.3.2/lib/cliver.rb:24:in `detect!'
     1: from /Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/cliver-0.3.2/lib/cliver/dependency.rb:116:in `detect!'
/Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/cliver-0.3.2/lib/cliver/dependency.rb:143:in `raise_not_found!': Could not find an executable ["phantomjs"] on your path. (Cliver::Dependency::NotFound)

我在各个方面都遇到了类似的问题,并且大多数修复都在代码中(某些require语句在彼此之间循环),但是该程序可以在我的另一台Macbook上运行,而没有这些错误。他们的存储库已同步,我什至尝试查看代码以确保它们相同。我还使用bundle list比较了宝石的版本和它们匹配的版本。这是gemfile,以备不时之需。

source "https://rubygems.org"

gem 'pry'
gem 'pry-rescue' 
gem 'pry-stack_explorer'
gem 'pry-nav'
gem 'poltergeist'
gem 'nokogiri'
gem 'rspec'
gem 'require_all'

两台Macbook都运行相同版本的Mojave,我不认为会导致这种情况的系统有所不同。它们应该都在同一版本的宝石和捆绑器等上。

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

此行

/Users/TuzsNewMacBook/.rvm/gems/ruby-2.5.1/gems/cliver-0.3.2/lib/cliver/dependency.rb:143:in `raise_not_found!': Could not find an executable ["phantomjs"] on your path. (Cliver::Dependency::NotFound)

解释为什么您的项目无法在另一台计算机上运行。

Gem poltergeist是Capybara的PhantomJS驱动程序。要使其正常工作,您需要安装phantomjs(无头浏览器)。您可以从PhantomJS官方网站下载它:

http://phantomjs.org/download.html

确保安装相同版本。为此,请在第一台Macbook终端中运行以下命令:

phantomjs -v

查找已安装的版本,然后在第二台Macbook上安装相同的版本。