Could not find an executable /home/ubuntu/.phantomjs/2.1.1/x86_64-linux/bin/phantomjs that matched the requirements '>= 1.8.1', '< 3.0'

54 views Asked by At
Cliver::Dependency::NotFound:Could not find an executable ["phantomjs"] on your path

I'm doing scraping/processing for some of my data using capybara. I have following gem installed

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

I'm getting error => Could not find an executable '/home/ubuntu/.phantomjs/2.1.1/x86_64-linux/bin/phantomjs' that matched the requirements

When I run following code

Capybara.register_driver :poltergeist do |app|
  Capybara::Poltergeist::Driver.new(app, {
    js_errors: false,
    timeout: 120,
    phantomjs: Phantomjs.path,
    phantomjs_options: [
      '--load-images=no',
      '--ignore-ssl-errors=yes',
      '--ssl-protocol=any'
    ]}
   )
 end
 Capybara.default_max_wait_time = 60
 @session = Capybara::Session.new(:poltergeist)
 @session.driver.headers = {"User-Agent" => user_agent}

This how I installed phantomjs

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev

Install these packages needed by PhantomJS to work correctly.

sudo apt-get install libfreetype6 libfreetype6-dev
sudo apt-get install libfontconfig1 libfontconfig1-dev

Get it from the PhantomJS website.

cd ~
export PHANTOM_JS="phantomjs-1.9.8-linux-x86_64"
wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
sudo tar xvjf $PHANTOM_JS.tar.bz2

Once downloaded, move Phantomjs folder to /usr/local/share/ and create a symlink:

sudo mv $PHANTOM_JS /usr/local/share
sudo ln -sf /usr/local/share/$PHANTOM_JS/bin/phantomjs /usr/local/bin

Now, It should have PhantomJS properly on your system.`

phantomjs --version

Also created symbolic link some thing like

sudo ln -s /home/ubuntu/.phantomjs/2.1.1/x86_64-linux/bin/phantomjs  /usr/local/bin/
sudo ln -s /home/ubuntu/.phantomjs/2.1.1/x86_64-linux/bin/phantomjs  /usr/bin/
sudo ln -s /home/ubuntu/.phantomjs/2.1.1/x86_64-linux/bin/phantomjs  /usr/local/share/

Also gave persmission chmod +x installed phantomjs.sh

But nothing worked for me.

0

There are 0 answers