user3142658
user3142658

Reputation: 39

Cannot execute PhantomJS on Linux

Have been trying to install latest version (1.9.8) of phantomjs on Ubuntu 12.04 VM without success. Here's what I did so far:

  1. To get rid of old version, executed

    sudo apt-get remove phantomjs
    
  2. To get rid of old symlinks, executed

    rm -r /.../phantomjs
    
  3. Downloaded phantomjs-1.9.8-linux-x86_64.tar.bz2.2 into /usr/local/share dir and extracted:

    sudo wget . . ..tar.bz2
    sudo tar xjf phantomjs-1.9.8-linux-x86_64.tar.bz2
    
  4. Created new symlinks to /usr/local/share/, /usr/local/bin/ and /usr/bin

    sudo ln -s /usr/local/share/phantomjs-1.9.8-linux-x86_64/bin/phantomjs  /usr/. . ./phantomjs
    
  5. Checked version:

    phantomjs --version 
    

This is the message that is returned:

-bash: /usr/local/bin/phantomjs: cannot execute binary file

Could someone explain why this is happening and what to do to fix it?

Upvotes: 2

Views: 6316

Answers (2)

Bhaskar Bhatt
Bhaskar Bhatt

Reputation: 1467

I had the same issue then I followed following things for the usage

Step-1

First go to http://phantomjs.org/download.html and download zip file for your system version which match 32-bit or 64-bit

Step-2

Extract Downloaded zip file

Step-3

Open Terminal Then reach to extracted folder then it will have bin folder

Step-4

Run the below Command

 > sudo cp phantomjs /bin

After that run phantomjs command

> phantomjs -v
2.1.1

Upvotes: 0

user3142658
user3142658

Reputation: 39

Was given suggestion to use npm to install:

sudo apt-get install nodejs npm 

Had problems:

. . . 
nodejs is already the newest version. 
Some packages could not be installed. 
This may mean that you have requested an impossible situation or 
if you are using the unstable distribution that some required packages have not yet been created
or been moved out of Incoming. The following information may help resolve the situation:
The following packages have unmet dependencies:
 nodejs : Conflicts: npm
E: Unable to correct problems, you have held broken packages.

Was informed that simple apt-get install nodejs installs npm as well, so tried that, followed by

sudo npm -g install phantomjs 

Finally:

... 
Done. Phantomjs binary available at /usr/lib/node_modules/phantomjs/lib/phantom/bin/phantomjs [email protected]
 /usr/lib/node_modules/phantomjs 
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], 
      [email protected], [email protected], [email protected]) 
└── [email protected] ([email protected], [email protected], [email protected], 
[email protected], [email protected], [email protected], [email protected], [email protected], 
[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], 
[email protected]) 

Checked version:

sudo phantomjs --version 
1.9.8 

As final proof of it being installed and working, re-ran previously failing cucumber tests (couldn't pass because phantomjs was missing), and all cucumber tests dependent on phantomjs now pass

Upvotes: 1

Related Questions