Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot start PhantomJS #1270

Closed
etiennebr opened this issue Dec 19, 2014 · 21 comments
Closed

Cannot start PhantomJS #1270

etiennebr opened this issue Dec 19, 2014 · 21 comments

Comments

@etiennebr
Copy link

Hello, this seems to be somewhat related to issue #558. However I'm new to all this (npm, grunt, karma) and I'm not really sure of the identity of the problem.

When I
grunt karma:unit
I get this sad result

Running "karma:unit" (karma) task
INFO [karma]: Karma v0.12.28 server started at http://localhost:8080/
INFO [launcher]: Starting browser PhantomJS
ERROR [launcher]: Cannot start PhantomJS
    Error: spawn EACCES
INFO [launcher]: Trying to start PhantomJS again (1/2).
ERROR [launcher]: Cannot start PhantomJS
    Error: spawn EACCES
INFO [launcher]: Trying to start PhantomJS again (2/2).
ERROR [launcher]: Cannot start PhantomJS
    Error: spawn EACCES
ERROR [launcher]: PhantomJS failed 2 times (cannot start). Giving up.
Warning: Task "karma:unit" failed. Use --force to continue.
Aborted due to warnings.

With my limited understanding I've tried installing and reinstalling (global and/or not) phantomjs but it didn't work out.

I'm on Ubuntu 12.04
karma@0.12.28
node@0.10.34
phantomjs@1.9.12

However, when I $ phantomjs --version, I get 1.9.8. which is odd. Checking on the phantomjs website seems to confirm the latests release is phantomjs 1.9.8.

$ npm remove phantomjs -g
unbuild phantomjs@1.9.12
$ npm remove phantomjs
unbuild phantomjs@1.9.12
$  phantomjs --version
bash: ~/.npm-packages/bin/phantomjs: No such file or directory

So I don't think there's another installation that karma could refer to. At this point, when I launch grunt karma:unit it accordingly say that phantomjs isn't there.

Then I reinstalled phantomjs

$ npm install phantomjs

> phantomjs@1.9.12 install ~/mytodo/node_modules/phantomjs
> node install.js

Downloading https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
Saving to /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2
Receiving...
  [======================================--] 95% 0.0s
Received 12854K total.
Extracting tar contents (via spawned process)
Removing /media/Fermi/workspace/mytodo/node_modules/phantomjs/lib/phantom
Copying extracted folder /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2-extract-1418991182513/phantomjs-1.9.8-linux-x86_64 -> ~/mytodo/node_modules/phantomjs/lib/phantom
Removing /tmp/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2-extract-1418991182513
Writing location.js file
Done. Phantomjs binary available at ~/mytodo/node_modules/phantomjs/lib/phantom/bin/phantomjs
phantomjs@1.9.12 node_modules/phantomjs
├── which@1.0.8
├── progress@1.1.8
├── rimraf@2.2.8
├── ncp@1.0.1
├── kew@0.4.0
├── adm-zip@0.4.4
├── request-progress@0.3.1 (throttleit@0.0.2)
├── mkdirp@0.5.0 (minimist@0.0.8)
├── npmconf@2.0.9 (uid-number@0.0.5, inherits@2.0.1, osenv@0.1.0, ini@1.3.2, once@1.3.1, semver@4.1.0, nopt@3.0.1, config-chain@1.1.8)
└── request@2.42.0 (caseless@0.6.0, json-stringify-safe@5.0.0, aws-sign2@0.5.0, forever-agent@0.5.2, stringstream@0.0.4, oauth-sign@0.4.0, tunnel-agent@0.4.0, qs@1.2.2, node-uuid@1.4.2, mime-types@1.0.2, tough-cookie@0.12.1, http-signature@0.10.0, form-data@0.1.4, bl@0.9.3, hawk@1.1.1)

Still, karma complains Cannot start PhantomJS Error: spawn EACCES.

@maksimr
Copy link
Contributor

maksimr commented Dec 19, 2014

@etiennebr remove global phantomjs and install it to the project

@etiennebr
Copy link
Author

Nope :(

$ npm remove phantomjs
$ npm remove phantomjs -g
$ npm install phantomjs

Then still that error...

$ grunt karma:unit
[...]
ERROR [launcher]: Cannot start PhantomJS
    Error: spawn EACCES
[...]

@maksimr
Copy link
Contributor

maksimr commented Dec 19, 2014

Do you have env variable PHANTOMJS_BIN?

echo $PHANTOMJS_BIN

@etiennebr
Copy link
Author

I added it to my .bashrc. ~/mytodo/node_modules/phantomjs/lib/phantom/bin/phantomjs.
And I should be able to execute.

ls -l $PHANTOMJS_BIN 
-rwxr-xr-x 1 etienne etienne 38346752 dec 19 09:21 ~/mytodo/node_modules/phantomjs/lib/phantom/bin/phantomjs

@maksimr
Copy link
Contributor

maksimr commented Dec 19, 2014

@etiennebr seems karma does not have access to this file.
Try remove/unset variable PHANTOMJS_BIN and run karma in project.

@maksimr
Copy link
Contributor

maksimr commented Dec 19, 2014

@etiennebr karma installed locally?

@etiennebr
Copy link
Author

How can I change access for karma ? I removed karma globally and installed it locally only, but still the same issue.

$ npm remove karma -g
$ npm remove karma
$ npm install karma
$ grunt karma
[...]
ERROR [launcher]: Cannot start PhantomJS
    Error: spawn EACCES
[...]

While installation seems to work fine, karma isn't in ./node_modules/.bin/karma[1] but in ./node_modules/karma/bin/karma, looking around, I think it's normal though.

$ ./node_modules/karma/bin/karma start
bash: ./node_modules/karma/bin/karma: Permission denied
$ ls -l ./node_modules/karma/bin/karma
-rwxrwxrwx 1 etienne etienne 50 nov 25 10:26 ./node_modules/karma/bin/karma

Now after some googling it seems related to file access, and similar to http://stackoverflow.com/questions/26968388/executing-karma-giving-permission-denied-error, but chmod 777 didn't make it. On phantomjs issues, I found Medium/phantomjs#102, but using sudo doesn't seem to apply; I've used this solution instead https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md.

1: the directory stated in doc http://karma-runner.github.io/0.8/intro/installation.html

@maksimr
Copy link
Contributor

maksimr commented Dec 20, 2014

Hm... really very strange behavior. Myself I use Ubuntu and never met such problems on 12 and 14

As a suggestion try use nvm and install karma-cli globally for running karma from console(karma start):

npm install -g karma-cli

Thanks!

@maksimr
Copy link
Contributor

maksimr commented Dec 20, 2014

Close, because problem does not in karma itself.

@maksimr maksimr closed this as completed Dec 20, 2014
@egeland
Copy link

egeland commented Jun 30, 2015

Just wanted to note, as I had a similar issue today - phantomjs on Ubuntu needs the libfontconfig package (and/or the libfontconfig-dev package - I installed both) or it won't start..

@dominicumbeer
Copy link

@egeland Your solution fixed the problem. The package was missing on my Ubuntu. I got following error message:

INFO [karma]: Karma v0.12.37 server started at http://localhost:9018/
INFO [launcher]: Starting browser PhantomJS
ERROR [launcher]: Cannot start PhantomJS

INFO [launcher]: Trying to start PhantomJS again (1/2).
ERROR [launcher]: Cannot start PhantomJS

INFO [launcher]: Trying to start PhantomJS again (2/2).
ERROR [launcher]: Cannot start PhantomJS

ERROR [launcher]: PhantomJS failed 2 times (cannot start). Giving up.

Unfortunately this message does not give any hints about the problem, so I'm happy that I found your post.

@egeland
Copy link

egeland commented Jun 30, 2015

@dominicumbeer Glad it helped - your errors are exactly what I was seeing today.

So mysterious, until you run phantomjs by itself (not with --version), then you see the cause..

@tjmonsi
Copy link

tjmonsi commented Jun 30, 2015

@egeland : Good thing I found this post. I'm also having problems with PhantomJS not running in Karma in Meteor's velocity JS

Kudos to you :)

@luxueyan
Copy link

@egeland Me too!

npm install phantomjs
npm install grunt-karma
npm install karma
npm install karma-cli
npm install karma-phantomjs-launcher

grunt karma & karam start & sudo karam start all not work, but sudo grunt karma works fine

  ✗ karma start
ERROR [launcher]: Cannot start PhantomJS
    Error: spawn EACCES
ERROR [launcher]: Cannot start PhantomJS
    Error: spawn EACCES
ERROR [launcher]: Cannot start PhantomJS
    Error: spawn EACCES
ERROR [launcher]: PhantomJS failed 2 times (cannot start). Giving up.
------
✗ sudo karma start
Password:

sudo karma start is stuck

@egeland
Copy link

egeland commented Jul 14, 2015

@luxueyan Did you install the packages as I mentioned above?
Did you try running phantomjs by itself, no options?

@luxueyan
Copy link

@egeland Sorry, i didn't say my system is os x 10.9.5.
I run phantomjs by itself well without any options.
In my project

node_modules/phantomjs/bin/phantomjs

Now the only works way for me is : sudo grunt karma.
Thanks!

@alexserver
Copy link

@egeland +1 to your solution. Thank you very much for helping us !

@jangaraj
Copy link

jangaraj commented Aug 8, 2015

RHEL/CentOS solution:

yum install -y fontconfig freetype-devel

@pscheit
Copy link

pscheit commented May 20, 2017

i think libfontconfig-dev isnt required (debian:jessie)

@justindiaw
Copy link

@egeland Thank you so much! You saved my day!

@icfantv
Copy link

icfantv commented Jun 1, 2018

Just a note for others that we came across this issue when the script being executed wasn't actually executable. That is, a simple chmod +x SCRIPT_NAME fixed it for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests