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

0.1.3: Cannot start PhantomJS #31

Closed
gillius opened this issue Apr 2, 2014 · 45 comments

Comments

Projects
None yet
@gillius
Copy link

commented Apr 2, 2014

After upgrading 0.1.2 to 0.1.3, I get the error message:

Running "karma:unit" (karma) task
INFO [karma]: Karma v0.12.2 server started at http://localhost:9001/
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.
Warning: Task "karma:unit" failed. Use --force to continue.

There's no delays between the starting and cannot start messages.

I'm using "^0.1.2" dependency on karma-phantomjs-launcher so I had 2 systems yesterday upgrade to 0.1.3. One is Windows XP and the other Windows 7, both are running nodejs 0.10.26 and phantomjs 1.9.7. On one system phantomjs is in the path, in the other case, karma-phantomjs-launcher is using the version it downloaded itself into its lib folder. I'm running this from grunt. Initially I was using karma 0.10 but tried to upgrade to 0.12.2 to resolve the error with no luck.

Ultimately, I discovered that reverting karma-phantomjs-launcher to 0.1.2 fixes the problem. If I "npm install karma-phantomjs-launcher@0.1.2" then build works, if I install 0.1.3 then it fails. This is consistent even when starting from existing project or when deleting all node_modules and allowing npm to totally refresh everything.

@ToshB

This comment has been minimized.

Copy link

commented Apr 2, 2014

I just had the same issue.
0.1.2 tries to run phantomjs.exe from:

karma-phantomjs-launcher\node_modules\phantomjs\lib\phantom\phantomjs.exe

0.1.3 tries to run phantomjs.exe from the invalid location:

karma-phantomjs-launcher\node_modules\phantomjs\lib\phantom\node_modules\phantomjs\bin\phantomjs
@sylvain-hamel

This comment has been minimized.

Copy link
Contributor

commented Apr 2, 2014

@ToshB,

Can you please edit the karma-phantomjs-launcher\index.js to add the 3 console.log here. Just replace the win32PhantomJSPath function with this one:

var win32PhantomJSPath = function () {
  // get the path stored in phantomjs\lib\location.js, someting like
  //   "C:\\Users\\user-name\\AppData\\Roaming\\npm\\phantomjs.CMD"
  var cmd = require('phantomjs').path;
  console.log("cmd:", cmd);

  // get the global npm install directory by removing the filename from cmd variable
  var npmGlobalRoot = path.dirname(cmd);
  console.log("npmGlobalRoot:", npmGlobalRoot);

  // add known path
  var phantom = npmGlobalRoot + '\\node_modules\\phantomjs\\bin\\phantomjs';
  console.log("phantom:", phantom);

  return phantom;
};

On my PC I get this logged out:

cmd: C:\Users\shamel\AppData\Roaming\npm\phantomjs.CMD
npmGlobalRoot: C:\Users\shamel\AppData\Roaming\npm
phantom: C:\Users\shamel\AppData\Roaming\npm\node_modules\phantomjs\bin\phantomjs

Thanks

@ToshB

This comment has been minimized.

Copy link

commented Apr 2, 2014

I get this on the build server. Note that I have not installed phantomjs globally.

cmd: D:\TeamCity\buildAgent\work\f97b90bf5e54ad14\MyApp\node_modules\phantomjs\lib\phantom\phantomjs.exe
npmGlobalRoot: D:\TeamCity\buildAgent\work\f97b90bf5e54ad14\MyApp\node_modules\phantomjs\lib\phantom
phantom: D:\TeamCity\buildAgent\work\f97b90bf5e54ad14\MyApp\node_modules\phantomjs\lib\phantom\node_modules\phantomjs\bin\phantomjs
@sylvain-hamel

This comment has been minimized.

Copy link
Contributor

commented Apr 2, 2014

Can you install it globally just to see if it solves the problem. If that's the case you will have a workaround for today and I'll fix it tonight.

@ToshB

This comment has been minimized.

Copy link

commented Apr 2, 2014

Sorry, I do not have time to try this now, maybe someone else can assist.

@kenwarner

This comment has been minimized.

Copy link

commented Apr 2, 2014

I'm also having this issue. thanks for the quick turnaround on PR #32

mikaelbr added a commit to mikaelbr/karma-phantomjs-launcher that referenced this issue Apr 2, 2014

@margielm

This comment has been minimized.

Copy link

commented Apr 3, 2014

Hello,

Yesterday I have lost half a day before I noticed that there is a new version of the runner :(

mikaelbr added a commit to mikaelbr/karma-phantomjs-launcher that referenced this issue Apr 3, 2014

chad-configit added a commit to chad-configit/karma-phantomjs-launcher that referenced this issue Apr 3, 2014

fix: Switched from launching phantomjs via node to ensuring the .exe …
…is always

launched if the path is reported as a .cmd file
Fixes karma-runner#31

chad-configit added a commit to chad-configit/karma-phantomjs-launcher that referenced this issue Apr 3, 2014

fix: Switched from launching phantomjs via node to ensuring that
the .exe is always launched if the path is reported as a .cmd file
Fixes karma-runner#31
@philippd

This comment has been minimized.

Copy link

commented Apr 3, 2014

+1, please fix this

@ghost

This comment has been minimized.

Copy link

commented Apr 3, 2014

I'm also running into this issue.

@zfleet

This comment has been minimized.

Copy link

commented Apr 4, 2014

I'm running into this issue too.

@juristr

This comment has been minimized.

Copy link

commented Jun 26, 2014

I'm still somehow experiencing this issue. On our Windows-based Jenkins, I have PhantomJS installed globally, however, launching the grunt test which starts karma:unit doesn't work as it apparently doesn't find any PhantomJS binary and instructs me to set the PHANTOMJS_BIN environment variable. This is really strange as when typing phantomjs into the shell on Jenkins (with the user that executes the job, I get access to phantomjs, just as expected.

On the other side, when I provide the PHANTOMJS_BIN and make it point to phantomjs.cmd in the global npm directory, the process hangs (as described above). I have to manually set it to the phantomjs.exe to have it work as apparently the phantomJSExePath() is not executed when providing the phantomjs environment variable.

@jhuesos

This comment has been minimized.

Copy link

commented Jun 26, 2014

I am experiencing also the issue when PhantomJS get stucked when running tests and it displays:

Disconnected (1 times), because no message in 10000 ms.

@sylvain-hamel

This comment has been minimized.

Copy link
Contributor

commented Jun 26, 2014

@juristr Something changed this week in the phantomjs@1.9.7-10 module. It was working fine with phantomjs@1.9.7-9. They don't return the path that phantomJSExePath() expects anymore.

We'll have to investigate and find out if they broke it accidentally or if it's how it works now.

In the meantime you can point PHANTOMJS_BIN to the exe location or you can downgrade to phantomjs@1.9.7-9. If you choose to downgrade, make sure you npm uninstall karma-phantom-js and then npm install karma-phantom-js.

I'm reopening this issue. I'll try to fix the launcher asap.

@sylvain-hamel sylvain-hamel reopened this Jun 26, 2014

@juristr

This comment has been minimized.

Copy link

commented Jun 26, 2014

Perfekt 👍

Meanwhile, for anybody having the same issue, just do what phantomJSExePath() does internally, set the PHANTOMJS_BIN environment variable to the phantomjs.exe. That works.

@sylvain-hamel

This comment has been minimized.

Copy link
Contributor

commented Jul 2, 2014

Got a confirmation that this is a bug in the phantomjs module. See Medium/phantomjs#194. I'll test again when they release a fix and then close this issue.

@bitwit

This comment has been minimized.

Copy link

commented Jul 21, 2014

I just wanted to note here that I was having this issue with the latest versions of launcher and phantom and what solved the problem for me was installing libfontconfig

see: ariya/phantomjs#10904 (comment)

@rquinlivan

This comment has been minimized.

Copy link

commented Aug 4, 2014

I am getting this issue with 0.1.4 as well

@johnpapa

This comment has been minimized.

Copy link

commented Sep 28, 2014

Having this same issue with:

"karma-phantomjs-launcher": "^0.1.4",
"phantomjs": "^1.9.10",
@OWOWORLD

This comment has been minimized.

Copy link

commented Dec 17, 2014

+1 on libfontconfig fix thanks

@lavaxun

This comment has been minimized.

Copy link

commented Jan 2, 2015

+1 libfontconfig thanks

@tschaub

This comment has been minimized.

Copy link

commented Jan 4, 2015

This gist got me set up for Ubuntu 12.04.5. These were the missing packages:

    apt-get install libfreetype6 libfreetype6-dev libfontconfig1 libfontconfig1-dev
@affablebloke

This comment has been minimized.

Copy link

commented Jan 26, 2015

+1 on libfontconfig works

@paulbhartzog

This comment has been minimized.

Copy link

commented Feb 2, 2015

+1 on libgontconfig
sudo apt-get install libfontconfig

@rcheuk

This comment has been minimized.

Copy link

commented Feb 12, 2015

+1 on libfontconfig

@hao1939

This comment has been minimized.

Copy link

commented Feb 25, 2015

+1 on libfontconfig, thanks @bitwit !

froddd pushed a commit to ministryofjustice/manchester_traffic_offences_pleas that referenced this issue Mar 5, 2015

Fred Marecesche
Fix 'Cannot start PhantomJS' error
Running `gulp test` was failing on starting PhantomJS. Fixed by
installing libfontconfig:
karma-runner/karma-phantomjs-launcher#31 (comment)

[MAPDEV196]
@tornabene

This comment has been minimized.

Copy link

commented Mar 13, 2015

thanks
libfontconfig installation worked for me as well 👍 (14.04 LTS)

@franleplant

This comment has been minimized.

Copy link

commented Apr 3, 2015

I was having the same problem and it was solved by sudo apt-get install libfontconfig

@tot-ra

This comment has been minimized.

Copy link

commented Apr 22, 2015

Got same problem, karma-phantomjs-launcher: 0.1.4 , phantomjs: 1.9.8 on centos, and libfontconfig is not available

@mdichirico

This comment has been minimized.

Copy link

commented May 7, 2015

For CentOS:
sudo yum install freetype
sudo yum install fontconfig
I found that info from this helpful page: http://www.sameerhalai.com/blog/how-to-install-phantomjs-on-a-centos-server/

@dignifiedquire

This comment has been minimized.

Copy link
Member

commented May 18, 2015

I'm closing this issue as it seems all remaining problems are due to the installation process of phantomjs. Please file a new issue if there is something we can actually do to help with this.

@martinsznapka

This comment has been minimized.

Copy link

commented Sep 23, 2015

+1 on libfontconfig (fixed my Docker image)

@puffnfresh

This comment has been minimized.

Copy link

commented Oct 5, 2015

The problem for NixOS is that the /lib64/ld-linux-x86-64.so.2 interpreter doesn't exist. The solution is to have the phantomjs derivation from nixpkgs in your shell, npm install phantomjs will find the existing binary.

@danielyaa5

This comment has been minimized.

Copy link

commented Oct 27, 2015

npm install phantomjs fixed this for me on Mac OS X

@arikogan

This comment has been minimized.

Copy link

commented Dec 8, 2015

Thanks a lot for the tip @jan-tomsa, libfontconfig did the trick.

@sg28

This comment has been minimized.

Copy link

commented Jan 21, 2016

I faced the same issue,the solution that worked for me is to run
sudo yum install fontconfig ,
The command has to be executed at the right location ,but this Works..

@roomond

This comment has been minimized.

Copy link

commented May 16, 2016

Having this issue with suggested solution of *fontconfig, *freetype on Ubuntu 14.04 and with:

"karma-phantomjs-launcher": "1.0.0", "phantomjs": "1.9.8",

@deltreey

This comment has been minimized.

Copy link

commented Jul 4, 2016

I don't know why fontconfig works, but it works for me too.

@volosovich

This comment has been minimized.

Copy link

commented Oct 31, 2016

in local directory run npm install phantomjs
it works for me
MacOs 10.11.6

@LironHazan

This comment has been minimized.

Copy link

commented Nov 2, 2016

npm install phantomjs for MacOs didn't solve it for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.