Cliver::Dependency::NotFound:Could not find an executable ["phantomjs"] on your path. error on Jenkins

Viewed 4639

I am getting this error while building the project on Jenkins . The execution is running hassle free on my local machine . I have added these to my Gemfile .

gem 'poltergeist'
gem 'capybara'
gem 'phantomjs'

The error only occurs on jenkins. using phantomjs 2.1.1.0

3 Answers

if you're using Rails' system tests, you'll need to pass proper options to the driver to have it use PhantomJS from the phantomjs gem:

require 'phantomjs'

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
  driven_by :poltergeist, options: { phantomjs: Phantomjs.path }
end

This script worked for me

#!/usr/bin/env bash
# This script install PhantomJS in your Debian/Ubuntu System
#
# This script must be run as root:
# sudo sh install_phantomjs.sh
#

if [[ $EUID -ne 0 ]]; then
    echo "This script must be run as root" 1>&2
    exit 1
fi

PHANTOM_VERSION="phantomjs-2.1.1"
ARCH=$(uname -m)

if ! [ $ARCH = "x86_64" ]; then
    $ARCH="i686"
fi

PHANTOM_JS="$PHANTOM_VERSION-linux-$ARCH"

apt-get update
apt-get install build-essential chrpath libssl-dev libxft-dev -y
apt-get install libfreetype6 libfreetype6-dev -y
apt-get install libfontconfig1 libfontconfig1-dev -y

cd ~
wget https://bitbucket.org/ariya/phantomjs/downloads/$PHANTOM_JS.tar.bz2
tar xvjf $PHANTOM_JS.tar.bz2

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

Give the file executable permissions

chmod +x install_phantomjs.sh

Then push to git to rebuild

git add install_phantomjs.sh
git commit -m 'Install PhantomJS'
git push

NB: Find the latest PhantomJS versions here https://bitbucket.org/ariya/phantomjs/downloads/, then you can edit the PHANTOM_VERSION env variable appropriately

Related