2015-06-08 9 views
23

ottenendo il seguente errore quando si tenta di utilizzare phantomjs da Ruby su Ubuntu:Impossibile trovare 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)>' 

phantomjs è stato costruito a livello locale e aggiunto al PATH. Come faccio a ruby ​​a trovare i phantomjs?

risposta

3

A quanto pare, la soluzione era quella di aggiungere phantomjs non solo al PATH, ma creare anche collegamenti:

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 

Regolare le /home/myuser/phantomjs/bin/phantomjs percorsi per abbinare il percorso phantomjs binario sulla vostra macchina.

27

Si può anche fare

$ sudo apt-get install phantomjs        

Questo dovrebbe aggiungere automaticamente phantomjs al percorso, e fare tutto il resto necessario che per funzionare correttamente. Questo ha funzionato per me.

+0

Il problema per me era che apt-get installa una versione precedente (1.9.0), mentre mi serviva 2.0.0 –

+1

'E: Impossibile trovare il pacchetto phantomjs' –

+0

grazie. questo ha funzionato per me. :) –

27

Invece di costruire localmente, usa homebrew sul tuo Mac con brew install phantomjs e tutti i percorsi si collegheranno dopo. Ho avuto questo errore me stesso, e otterrete i collegamenti gratuitamente e avere la possibilità di aggiornare facilmente.

+0

Come indicato nella domanda, si tratta di phantomjs su Ubuntu, non Mac. –

+3

Come Google ha dimostrato, questo è il risultato migliore per qualsiasi cosa abbia a che fare con phantomjs e quell'errore. 3 upvotes dimostrano anche che è necessario correggere la domanda in quanto non è specifica per il sistema operativo. – pjammer

8

metti in Gemfile

gem 'phantomjs', :require => 'phantomjs/poltergeist' 

o inserire il codice qui sotto per spec_helper.rb

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

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

11

Per Mac Os El Capitan uso seguente comando:

npm install -g phantomjs 

Sopra comando funziona solo se è stato installato npm, per l'installazione di npm:

brew install npm 
0

Altra soluzione possibile è quella di aggiungere i diritti eseguibili al file:

# 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 

Ed inoltre non è raccomandato dalla poltergeist da usare phantomjs da repository ufficiali di Ubuntu:

NON usare phantomjs dai repository ufficiali di Ubuntu es, dato che lo non funziona bene con il poltergeist.