Skip to content
This repository has been archived by the owner on Sep 7, 2022. It is now read-only.

0.1.3: Cannot start PhantomJS #31

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

0.1.3: Cannot start PhantomJS #31

gillius opened this issue Apr 2, 2014 · 45 comments

Comments

@gillius
Copy link

gillius 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 [email protected]" 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
Copy link

ToshB 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
Copy link
Contributor

@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
Copy link

ToshB 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
Copy link
Contributor

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
Copy link

ToshB commented Apr 2, 2014

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

@kenwarner
Copy link

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
Copy link

margielm 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
@philippd
Copy link

philippd commented Apr 3, 2014

+1, please fix this

@ghost
Copy link

ghost commented Apr 3, 2014

I'm also running into this issue.

@zfleet
Copy link

zfleet commented Apr 4, 2014

I'm running into this issue too.

@juristr
Copy link

juristr 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
Copy link

jhuesos 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
Copy link
Contributor

@juristr Something changed this week in the [email protected] module. It was working fine with [email protected]. 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 [email protected]. 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
Copy link

juristr 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
Copy link
Contributor

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
Copy link

bitwit 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)

@ghost
Copy link

ghost commented Aug 4, 2014

I am getting this issue with 0.1.4 as well

@johnpapa
Copy link

Having this same issue with:

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

@pheuter
Copy link

pheuter commented Oct 20, 2014

Same:

"karma-phantomjs-launcher": "^0.1.4",
"phantomjs": "^1.9.11"

@jan-tomsa
Copy link

Confirming @bitwit 's advice.
sudo apt-get install libfontconfig
solved the problem for me
(TurnKey Node.JS VM 13 | [email protected], [email protected], [email protected])
Thank you.

@blimmer
Copy link

blimmer commented Nov 13, 2014

I can confirm that installing libfontconfig fixed this problem for me, too, on Ubuntu Server 14.04.1 LTS.

@NitBlockchain
Copy link

+1 on libfontconfig fix thanks

@lavaxun
Copy link

lavaxun commented Jan 2, 2015

+1 libfontconfig thanks

@tschaub
Copy link

tschaub 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
Copy link

+1 on libfontconfig works

@paulbhartzog
Copy link

+1 on libgontconfig
sudo apt-get install libfontconfig

@rcheuk
Copy link

rcheuk commented Feb 12, 2015

+1 on libfontconfig

@hao1939
Copy link

hao1939 commented Feb 25, 2015

+1 on libfontconfig, thanks @bitwit !

froddd added a commit to ministryofjustice/manchester_traffic_offences_pleas that referenced this issue Mar 5, 2015
Running `gulp test` was failing on starting PhantomJS. Fixed by
installing libfontconfig:
karma-runner/karma-phantomjs-launcher#31 (comment)

[MAPDEV196]
@tornabene
Copy link

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

@franleplant
Copy link

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

@tot-ra
Copy link

tot-ra 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
Copy link

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
Copy link
Member

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
Copy link

+1 on libfontconfig (fixed my Docker image)

@puffnfresh
Copy link

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
Copy link

npm install phantomjs fixed this for me on Mac OS X

@arikogan
Copy link

arikogan commented Dec 8, 2015

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

@sg28
Copy link

sg28 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
Copy link

roomond 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
Copy link

deltreey commented Jul 4, 2016

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

@volosovich
Copy link

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

@LironHazan
Copy link

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

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

No branches or pull requests