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

Please set env variable PHANTOMJS_BIN #69

Closed
AquilaSagitta opened this issue May 8, 2015 · 25 comments
Closed

Please set env variable PHANTOMJS_BIN #69

AquilaSagitta opened this issue May 8, 2015 · 25 comments
Assignees

Comments

@AquilaSagitta
Copy link

Can't get phantomjs to launch. I have installed karma and karma-phantomjs-launcher both locally and globally. I've tried reverting the versions and manually setting the environment variable but it still doesn't work. I can launch karma-chrome-launcher no problem but would prefer to use phantomjs. Is this a problem with phantomjs itself?

Windows 7, node 0.12, karma 12.31, karma-phantomjs-launcher 0.1.4, phantomjs 1.9.16

Any help is appreciated!

@dignifiedquire
Copy link
Member

Does phantomjs work for you independently of karma?

@AquilaSagitta
Copy link
Author

yup just installed phantomjs 2.0 from their site and did the quick start

@nfantone
Copy link

Same issue here.

INFO [karma]: Karma v0.12.36 server started at http://localhost:9099/
INFO [launcher]: Starting browser PhantomJS
ERROR [launcher]: Cannot start PhantomJS
    Can not find the binary node_modules/karma-phantomjs-launcher/node_modules/.bin/phantomjs
    Please set env variable PHANTOMJS_BIN

Ironically, exporting PHANTOMJS_BIN to some existing path seems to have no effect whatsoever. The issue is resolved by manually installing karma-phantomjs-launcher dependencies, by means of:

nfantone@thinkpad-t430 ~/dev/js/myproject $ cd node_modules/karma-phantomjs-launcher/
nfantone@thinkpad-t430 ~/dev/js/myproject/node_modules/karma-phantomjs-launcher $ npm install

This actually installs the expected phantomjs binary at ./bin, and makes tests run without problems.


  • Using local dependencies:
    "phantomjs": "^1.9.17",
    "karma": "^0.12.36",
    "karma-phantomjs-launcher": "^0.2.0"
  • No global npm binaries are installed (with -g).
  • npm version: 2.11.1.

@dignifiedquire
Copy link
Member

Could you show me the output of npm ls in the failing case please?

@nfantone
Copy link

Of course, here it is.

...and here is the output of the working scenario with the "extraneous" packages, after the manual installation of dependencies. Just in case.

@dignifiedquire
Copy link
Member

Okay it's as I expected, due to deduplication and being a peerDependency the phantomjs package gets moved to the top level, and so the path to it is node_modules/phantomjs instead of the expected node_modules/karma-phantomjs-launcher/node_modules/phantomjs.
Will have to fix the path detection in here. Thanks for your help in tracking this down.

@nfantone
Copy link

You are welcome. Glad to help.

@dignifiedquire
Copy link
Member

Okay so it looks like it's not us :( We are just using require('phantomjs').path which should export the correct path to the binary, but it looks like it doesn't in your case.
Could you do me a favor and open an issue here: https://github.com/Medium/phantomjs/issues with a reference to here.

@nfantone
Copy link

Are you positive on this, @dignifiedquire ? I have debugged the plugin and it seems as if require('phantomjs').path holds what it's expected to hold: the value of $PHANTOMJS_BIN. This property contains a correct path to a valid phantomjs binary. However, it does not seem to be using it, at all, during the execution.

@dignifiedquire
Copy link
Member

No I'm not sure as I can't reproduce it on my machine :/ which os/node version are you on?

@nfantone
Copy link

  • Linux Mint 17.1 "Rebecca".
  • Latest 0.12.4 node.

@dignifiedquire
Copy link
Member

@AquilaSagitta could you please provide the full log output with log level set to DEBUG

dignifiedquire added a commit to dignifiedquire/karma-phantomjs-launcher that referenced this issue Jun 13, 2015
@dignifiedquire
Copy link
Member

@nfantone could you please test the version in my pr #78 ? (You should be able to install it via npm install Dignifiedquire/karma-phantomjs-launcher#69-bin)

@AquilaSagitta
Copy link
Author

debug info @dignifiedquire requested. http://pastebin.com/XhSEppjh

@dignifiedquire
Copy link
Member

@AquilaSagitta thanks, if you want please try my pr #78 as well, I hope it fixes this issue

@nfantone
Copy link

@dignifiedquire Didn't solve the issue. Now the path is, indeed, absolute. But it's still a path to a non existent binary.

INFO [launcher]: Starting browser PhantomJS
ERROR [launcher]: Cannot start PhantomJS
    Can not find the binary /home/nfantone/dev/js/my-project/node_modules/karma-phantomjs-launcher/node_modules/karma-phantomjs-launcher/node_modules/.bin/phantomjs

@nfantone
Copy link

Ok, I feel dumb. I've discovered that my auto-generated karma.conf.js had this line:

process.env.PHANTOMJS_BIN = 'node_modules/karma-phantomjs-launcher/node_modules/.bin/phantomjs';

at the very beginning. Entirely missed it this whole time. Removed it and worked flawlessly, both your branch and the 0.2.0 version. Shame on me.

Nevertheless,

  1. Your modifications in Dignifiedquire/karma-phantomjs-launcher#69-bin are still reasonable.
  2. This very same karma.conf.js file has been like that in my repo since the beginning of time. And it has never been a problem up until the last update to 0.2.0. Also, it's obviously not a coincidence that installing the plugins dependencies manually, creates that .bin/phantomjs. Any ideas on why this could have happened?

We should wait for some input from @AquilaSagitta. But, apart form that, you could close this issue if you want.

Thank you very much, @dignifiedquire for your time and patience.

@dignifiedquire
Copy link
Member

Happy to hear that :)

@AquilaSagitta
Copy link
Author

I also have the

process.env.PHANTOMJS_BIN = 'node_modules/karma-phantomjs-launcher/node_modules/.bin/phantomjs';

in my karma.conf.js but thats pointing to the right place. I'll try removing it and let you know if that resolves the issue.

@AquilaSagitta
Copy link
Author

That seems to resolve the issue >.<

I karma was complaining that the plugin for phantomjs was missing tho. Thought karma shipped with phantomjs and chrome. I added karma-phantomjs-launcher to plugins and it worked fine.

@nfantone
Copy link

@AquilaSagitta Was your karma.conf.js created automatically by an app generator, such as yeoman or Slush?

I believe this is affecting users with existing/old setups created by those tools.

@nfantone
Copy link

in my karma.conf.js but thats pointing to the right place.

It isn't. Do a clean npm install and check the path. You'll see .bin does not exist. It used to be there, though, as my builds never failed until recently.

@AquilaSagitta
Copy link
Author

@nfantone Yes this project was scaffold with Slush (Gulp.js equivalent of Yeoman) probably 2-3 months ago.

You're right the clean install doesn't have a .bin directory with phantomjs however, it was correct before I did a clean install. The process.env.PHANTOMJS_BIN... doesn't seem to actually do anything even when I change the path karma still throws this error

ERROR [launcher]: Cannot start PhantomJS
        Can not find the binary ...\node_modules\karma-phantomjs-launcher\node_modules\.bin\phantomjs
        Please set env variable PHANTOMJS_BIN

NOTE this is with #78 installed

@nfantone
Copy link

@nfantone Yes this project was scaffold with Slush (Gulp.js equivalent of Yeoman) probably 2-3 months ago.

Exactly. So was ours. In that same window frame. (I have edited my previous answer where I wrote slug, instead of Slush)

I don't know if newer versions of Slush still include this, but we should open an issue over there.

@AquilaSagitta
Copy link
Author

If you want to go ahead and do that feel free. I still don't understand what's happening or why removing that process.env... seems to solve the issue, You seem to have a better understanding of the situation.

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

3 participants