karma-runner / karma-phantomjs-launcher

A Karma plugin. Launcher for PhantomJS.
MIT License
281 stars 131 forks source link

Mac Os Sierra "Cannot start PhantomJS" #138

Open superandrew opened 8 years ago

superandrew commented 8 years ago

However I am not 100% sure that this issue is related to Sierra, It seems the only thing changed in a project already configured and working.

12 09 2016 16:48:20.494:DEBUG [preprocessor.coverage]: Processing "/Users/anyuser/Documents/xcode/anyproject-backend/src/test/javascript/spec/components/auth/auth.services.spec.js".
12 09 2016 16:48:20.504:INFO [karma]: Karma v0.13.19 server started at http://localhost:9876/
12 09 2016 16:48:20.509:INFO [launcher]: Starting browser PhantomJS
12 09 2016 16:48:20.509:DEBUG [temp-dir]: Creating temp dir at /var/folders/dj/j_jl7qxx06x59n9tfmkxh6s40000gn/T/karma-44720688
12 09 2016 16:48:20.511:DEBUG [launcher]: /Users/anyuser/Documents/xcode/anyproject-backend/node_modules/phantomjs/lib/phantom/bin/phantomjs /var/folders/dj/j_jl7qxx06x59n9tfmkxh6s40000gn/T/karma-44720688/capture.js
12 09 2016 16:48:20.618:DEBUG [launcher]: Process PhantomJS exited with code 0
12 09 2016 16:48:20.618:ERROR [launcher]: Cannot start PhantomJS

12 09 2016 16:48:20.618:DEBUG [temp-dir]: Cleaning temp dir /var/folders/dj/j_jl7qxx06x59n9tfmkxh6s40000gn/T/karma-44720688
12 09 2016 16:48:20.622:INFO [launcher]: Trying to start PhantomJS again (1/2).
12 09 2016 16:48:20.623:DEBUG [launcher]: Restarting PhantomJS
12 09 2016 16:48:20.623:DEBUG [temp-dir]: Creating temp dir at /var/folders/dj/j_jl7qxx06x59n9tfmkxh6s40000gn/T/karma-44720688
12 09 2016 16:48:20.624:DEBUG [launcher]: /Users/anyuser/Documents/xcode/anyproject-backend/node_modules/phantomjs/lib/phantom/bin/phantomjs /var/folders/dj/j_jl7qxx06x59n9tfmkxh6s40000gn/T/karma-44720688/capture.js /var/folders/dj/j_jl7qxx06x59n9tfmkxh6s40000gn/T/karma-44720688/capture.js
12 09 2016 16:48:20.723:DEBUG [launcher]: Process PhantomJS exited with code 0
12 09 2016 16:48:20.723:ERROR [launcher]: Cannot start PhantomJS

12 09 2016 16:48:20.723:DEBUG [temp-dir]: Cleaning temp dir /var/folders/dj/j_jl7qxx06x59n9tfmkxh6s40000gn/T/karma-44720688
12 09 2016 16:48:20.724:INFO [launcher]: Trying to start PhantomJS again (2/2).
12 09 2016 16:48:20.724:DEBUG [launcher]: Restarting PhantomJS
12 09 2016 16:48:20.724:DEBUG [temp-dir]: Creating temp dir at /var/folders/dj/j_jl7qxx06x59n9tfmkxh6s40000gn/T/karma-44720688
12 09 2016 16:48:20.725:DEBUG [launcher]: /Users/anyuser/Documents/xcode/anyproject-backend/node_modules/phantomjs/lib/phantom/bin/phantomjs /var/folders/dj/j_jl7qxx06x59n9tfmkxh6s40000gn/T/karma-44720688/capture.js /var/folders/dj/j_jl7qxx06x59n9tfmkxh6s40000gn/T/karma-44720688/capture.js /var/folders/dj/j_jl7qxx06x59n9tfmkxh6s40000gn/T/karma-44720688/capture.js
12 09 2016 16:48:20.827:DEBUG [launcher]: Process PhantomJS exited with code 0
12 09 2016 16:48:20.827:ERROR [launcher]: Cannot start PhantomJS

12 09 2016 16:48:20.827:DEBUG [temp-dir]: Cleaning temp dir /var/folders/dj/j_jl7qxx06x59n9tfmkxh6s40000gn/T/karma-44720688
12 09 2016 16:48:20.829:ERROR [launcher]: PhantomJS failed 2 times (cannot start). Giving up.
12 09 2016 16:48:20.830:DEBUG [karma]: Run complete, exiting.
12 09 2016 16:48:20.830:DEBUG [launcher]: Disconnecting all browsers
12 09 2016 16:48:20.833:DEBUG [reporter.jenkins]: Xml results written to "/Users/anyuser/Documents/xcode/anyproject-backend/target/test-results/karma/TESTS-results.xml".
Warning: Task "karma:unit" failed. Use --force to continue.

Any Idea?

dana11235 commented 8 years ago

From what I can tell, the problem is caused by the version of PhantomJS installed by karma-phantomjs-launcher. When I run the phantomjs binary directly, it returns a segfault (11).

When I updated karma-phantomjs-launcher to the newest version (1.0.2), the binary no longer segfaults, and the tests complete successfully. I also updated Karma to 1.3.0, but not sure whether that's actually necessary

LyricL-Gitster commented 8 years ago

Same issue. I've noticed that using phantomjs v2 (included in v1.0.2 of karma-phantomjs-launcher) seems to work fine. However, some of the tests in my rather large project fail with the phantomjs 2. The only solution for me may be to go back to El Capitan until there is time to update phantomjs and the tests.

superandrew commented 8 years ago

in case anyone is depending on this task in a project, I can confirm that running the test using 'Chrome' works

DISCLAIMER: this is only intended as a workaround for someone who is using frameworks (like jHipsters) with this dependency which broke the building process such as me :)

in karma.conf.js

// Start these browsers, currently available:
        // - Chrome
        // - ChromeCanary
        // - Firefox
        // - Opera
        // - Safari (only Mac)
        // - PhantomJS
        // - IE (only Windows)
        browsers: ['Chrome'],//Was PhantomJS
jjgonecrypto commented 8 years ago

Sadly I too can't run Phantomjs2 due to some kind of race condition between my initial setup scripts (that setup external browserify deps) and the tests themselves which require those browserify externals (meaning I get Error: Cannot find module 'xxx'). This doesn't happen in Phantom 1.9. But that is unrelated to this, just a note for anyone else who might be caught up by it.

kayschmitt commented 7 years ago

Same issue. @superandrew work around works as a hack for now

hamxabaig commented 7 years ago

+1 , doesn't work in macOS sierra. Chrome takes too much time to load the test suite.

jjgonecrypto commented 7 years ago

@hamxabaig @kayschmitt Phantom2 doesn't work for you? I doubt anyone will patch Phantom 1.9 to support Sierra, so there's not much karma-phantomjs-launcher can do to help.

@llhupp have you been able to detect any patterns with the tests that fail in Phantom 2?

hamxabaig commented 7 years ago

@justinjmoses i'm upgrading to Phantom2. Will let you know in a bit.

hamxabaig commented 7 years ago

okay, Phantom v 2.1.1 solves this.

jjgonecrypto commented 7 years ago

I filed this for Phantom 1.9.8. https://github.com/ariya/phantomjs/issues/14558

iiNku commented 7 years ago

Same issue and I can't upgrade to Phantom v2...

Kamilius commented 7 years ago

Just got this error, unable to fix with any of updates.

jjgonecrypto commented 7 years ago

FWIW I worked around my particular problem (Phantom 2 upgrade) by ensuring all test bundles (we're using browserify) include all their dependencies rather than externalizing them.

accraze commented 7 years ago

I had this issue earlier this week but was able to run phantomjs from the command line. Adding export PHANTOMJS_BIN=/usr/local/bin/phantomjs to my .bashrc/.zshrc seemed to fix it.

kevinclerc commented 7 years ago

Just updated to OS Sierra and my setup don't work anymore.

Here is my part of package.json:

    "jasmine-core": "~2.5.2",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-coverage": "^1.1.1",
    "karma-htmlfile-reporter": "^0.3.4",
    "karma-jasmine": "^1.0.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "karma-phantomjs-launcher": "^1.0.2",
    "karma-systemjs": "^0.15.0",
    "karma-typescript-preprocessor": "^0.3.0",
    "phantomjs-prebuilt": "^2.1.13"`

when I run karma start then I get following error:

20 10 2016 10:47:18.951:DEBUG [middleware:karma]: custom files null null
20 10 2016 10:47:18.951:DEBUG [middleware:karma]: Serving static request /context.html
20 10 2016 10:47:18.952:DEBUG [web-server]: serving: /Users/clke/.nvm/versions/node/v6.6.0/lib/node_modules/karma/static/context.html
20 10 2016 10:47:18.954:DEBUG [web-server]: serving: /Users/clke/.nvm/versions/node/v6.6.0/lib/node_modules/karma/static/context.js
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
  You need to include some adapter that implements __karma__.start method!

PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
  You need to include some adapter that implements __karma__.start method!
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
  You need to include some adapter that implements __karma__.start method!

PhantomJS 2.1.1 (Mac OS X 0.0.0): Executed 0 of 0 ERROR (0.025 secs / 0 secs)

It drives me crazy I wasted already so much of time due to this error.

Anyone any idea?

Thx a lot

vicmancb commented 7 years ago

same issue, any idea?

jjgonecrypto commented 7 years ago

Another workaround for this is using Electron instead of Phantom via https://github.com/lele85/karma-electron-launcher. I managed to upgrade to Phantom 2.1..1 but tried using Electron as a POC and it ran our 10k specs in the same time as Phantom 2

Zeladgolan commented 7 years ago

My issue wasn't with Phantom js, I had to upgrade "grunt-contrib-jasmine": "^1.0.3".

danilosterrapid7 commented 7 years ago

You need to figure out what directory you have your node, npm-cache and npm (if you installed it out of node) installed. Then, you give permission of execute and read. Usually, the npm-cache is located at:

~/.npm/

to find out where is your node and npm:

which node
which npm

Note: Those commands above will probably give you the folder "bin" so, get the folder node and npm to apply the permission. E.g FOR: "/usr/local/Cellar/node/bin/" YOU'RE GONNA USE: "/usr/local/Cellar/node/" Then, apply the permissions. It should work:

sudo chmod -R +xr PATH_NPM_CACHE_HERE
sudo chmod -R +xr PATH_NPM_HERE
sudo chmod -R +xr PATH_NODE_HERE

Everytime when Mac OS updates (MAJOR Updates like maverick, mount lion, sierra) we lose some permissions. That is why those errors pop up.

Also, I upgrade from "karma-phantomjs-launcher@~0.1.4" to "karma-phantomjs-launcher@1.0.2".

danilosterrapid7 commented 7 years ago

Also, it might be helpful Issue: https://github.com/karma-runner/karma-phantomjs-launcher/issues/84 Comment: https://github.com/karma-runner/karma-phantomjs-launcher/issues/84#issuecomment-252054603

kurtommy commented 7 years ago

"phantomjs": "^2.1.3" solve problems for me in Mac Os sierra

obeyler commented 7 years ago

On mac sierra the bug is located at this place into karma-phantomjs-launcher/index.js I'm not familiar with javascript but it seems that phantom-source is null

TypeError: Path must be a string. Received null
   at assertPath (path.js:7:11)
    at Object.extname (path.js:1431:5)
    at phantomJSExePath (../node_modules/karma-phantomjs-launcher/index.js:19:12)

in the index.js file we can find:

var phantomJSExePath = function () {
 13   // If the path we're given by phantomjs is to a .cmd, it is pointing to a global copy.
 14   // Using the cmd as the process to execute causes problems cleaning up the processes
 15   // so we walk from the cmd to the phantomjs.exe and use that instead.
 16 
 17   var phantomSource = require('phantomjs-prebuilt').path
 18 
 19   if (path.extname(phantomSource).toLowerCase() === '.cmd') {
 20     var phantomPackage = require('phantomjs-prebuilt/package.json')
 21     return path.join(path.dirname(phantomSource), '//node_modules//phantomjs//lib//phantom//', phantomPackage.bin.phantomjs)
 22   }
 23 
 24   return phantomSource
 25 }
kennedy841 commented 7 years ago

npm install phantomjs@2.1.3 worked for me on mac Sierra

ghost commented 7 years ago

npm install phantomjs@2.1.3 worked for me on mac Sierra works also but it's when you use you would have this kind of error

nickjuntilla commented 7 years ago

Just updating the the launcher to "karma-phantomjs-launcher": "^1.0.0" in package.json, but I would probably upgrade the phantomjs package as well if you have control.

thesafetylemur commented 7 years ago

For what it's worth, I ran into this today. Adding export PHANTOMJS_BIN=/usr/local/bin/phantomjs to my .bash_profile resolved this for me.

qiluo commented 7 years ago

I ran into same error like @obeyler mentioned, looks like still not fixed?

TypeError: Path must be a string. Received null
   at assertPath (path.js:7:11)
    at Object.extname (path.js:1431:5)
    at phantomJSExePath (../node_modules/karma-phantomjs-launcher/index.js:19:12)
brainmonger commented 7 years ago

I'm running into the same issue still after upgrading to Sierra.

Tried: upgrading phantomjs to 2.1.1 upgrading karma-phantomjs-launcher to 1.0.4 adding export PHANTOMJS_BIN=/usr/local/bin/phantomjs to my .bash_profile updating permissions to: sudo chmod -R +xr PATH_NPM_CACHE_HERE sudo chmod -R +xr PATH_NPM_HERE sudo chmod -R +xr PATH_NODE_HERE

any other ideas?

SimenB commented 7 years ago

191 trying to fix Path must be a string. Received null, or at least provide a better error message

yagudaev commented 7 years ago

Found this error to also happen if you end up using Karma directly from github source. Turns out there is a difference between the Karma code on npm and the one on github. See: https://github.com/nano3labs/karma/pull/1.

It was falsely indicating this error for me. So make sure you don't use something like:

// package.json
"dependencies": {
  "karma": "karma-runner/karma"
}
mwq27 commented 7 years ago

Has anyone had any luck with this issue? I'm also on Sierra with phantom-prebuilt@2.1.7 and Karma@1.3.0.

spiritson commented 7 years ago

+1. Mac OS Sierra. Same issue

trextroy commented 7 years ago

Can someone please take a look the issue regarding Mac OS Sierra ? Its still giving the similar issue.

SimenB commented 7 years ago

@trextroy can you try yarn add simenb/karma-phantomjs-launcher#passed-null --dev or npm i -D simenb/karma-phantomjs-launcher#passed-null and see if it helps?

That's #191

giovanigenerali commented 7 years ago

I was getting the same issue on macOS Sierra 10.12.6 and after updated using these versions below it's working.

npm install karma-phantomjs-launcher@1.0.4 --save-dev
npm install phantomjs@2.1.3 --save-dev
trextroy commented 7 years ago

Still no luck @SimenB / @giovanigenerali . I switched my attention to Chrome instead of Phantom now.

alexweissman commented 6 years ago

Upgrading PhantomJS to 2.x seems to have allowed the installation to complete successfully. However, I am now getting an error in my tests when running from the command line:

Running PhantomJS...ERROR
>> 0 [ '' ]
Warning: PhantomJS exited unexpectedly with exit code null. Used --force, continuing.

I'm running tests that were written several years ago, so is it possible that they're simply not compatible with newer versions of PhantomJS?

SlothFriend commented 6 years ago

I had this issue after upgrading to High Sierra, and updating the karma-phantomjs-launcher package to latest fixed it.

snimavat commented 6 years ago

Updating to "karma-phantomjs-launcher@1.0.2" fixed it for me

felipe-muner commented 6 years ago

Same error for me =(