gruntjs / grunt-lib-phantomjs

Grunt and PhantomJS, sitting in a tree.
http://gruntjs.com/
MIT License
93 stars 63 forks source link

Space in Phantomas path causes error in Windows #95

Closed ts-web closed 8 years ago

ts-web commented 8 years ago

I'm running node 5.3.0 on Windows, with phantomjs@1.9.19 installed globally. So the path to phantom.CMD is C:\Program Files\nodejs\phantomjs.CMD (note the space in Program Files).

I am encountering an error when I run grunt mocha (which uses grunt-lib-phantomas):

PhantomJS threw an error:ERROR
 0 [ '\'C:\\Program\' is not recognized as an internal or external command,\r',
>>   'operable program or batch file.' ]
>> operable program or batch file. 1 [ '\'C:\\Program\' is not recognized as an internal or external command,\r',
>>   'operable program or batch file.' ]
Warning: PhantomJS exited unexpectedly with exit code 1. Use --force to continue.

So you see the problem is related to improper handling of a filepath containing a space.

I debugged the source code, and I saw that in lib/phantomjs.js (line 164), the code is calling grunt.util.spawn() with the cmd option having a value of C:\Program Files\nodejs\phantomjs.CMD.

I've tried working around it by surrounding the value in quotes, adding a backslash character before the space (i.e. binPath.replace(' ', '\\ ')), and using opts.cwd.But no luck.

The only other workaround is to not use global phantomjs...

Any insight / ideas? Thanks

Arkni commented 8 years ago

From what you described, this looks like an issue with https://github.com/Medium/phantomjs as it is the package that provides the path to PhantomJS binary. So please report the issue on their issue tracker.

Closing this for now, feel free to ask if you have followup questions.