Could not find phantomjs

后端 未结 6 1670
终归单人心
终归单人心 2021-01-01 09:57

Getting the following error when trying to use phantomjs from ruby on Ubuntu:

 Failure/Error: visit root_path
 Cliver::Dependency::NotFound:
   Could not fin         


        
相关标签:
6条回答
  • 2021-01-01 10:07

    Instead of building locally, use homebrew on your mac with brew install phantomjs and all the paths will link after. I had this error myself, and you'll get the links for free and have the ability to update easily.

    0 讨论(0)
  • 2021-01-01 10:07

    For Mac Os El Capitan use following command:

    npm install -g phantomjs
    

    Above command only works if you have installed npm, for installing npm:

     brew install npm
    
    0 讨论(0)
  • 2021-01-01 10:23

    Apparently, the solution was to add phantomjs not only to the PATH, but also create links:

    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
    

    Adjust the /home/myuser/phantomjs/bin/phantomjs paths to match the path to phantomjs binary on your machine.

    0 讨论(0)
  • 2021-01-01 10:25

    You can also do

    $ sudo apt-get install phantomjs                               
    

    That should automatically add phantomjs to your path, and do everything else necessary for it to run correctly. This worked for me.

    0 讨论(0)
  • 2021-01-01 10:32

    Other possible solution is to add executable rights to 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
    

    And also it is not recommended by poltergeist to use phantomjs from official Ubuntu repos:

    DO NOT use phantomjs from the official Ubuntu repositories, since it doesn't work well with poltergeist.

    0 讨论(0)
  • 2021-01-01 10:34

    add to Gemfile

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

    or put code below to 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

    0 讨论(0)
提交回复
热议问题