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

Mac Os Sierra "Cannot start PhantomJS" #138

Open
superandrew opened this issue Sep 12, 2016 · 40 comments
Open

Mac Os Sierra "Cannot start PhantomJS" #138

superandrew opened this issue Sep 12, 2016 · 40 comments

Comments

@superandrew
Copy link

superandrew commented Sep 12, 2016

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

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

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

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

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

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

@hamxabaig
Copy link

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

@jjgonecrypto
Copy link

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

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

@hamxabaig
Copy link

okay, Phantom v 2.1.1 solves this.

@jjgonecrypto
Copy link

I filed this for Phantom 1.9.8. ariya/phantomjs#14558

@iiNku
Copy link

iiNku commented Sep 27, 2016

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

carpeliam pushed a commit to vmware-archive/pulse that referenced this issue Sep 28, 2016
phantomjs has issue with sierra (see karma issue [here](karma-runner/karma-phantomjs-launcher#138)).  It's resolved with bumping the karma-phantomjs-launcher plugin to 1.0.2
@Kamilius
Copy link

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

@jjgonecrypto
Copy link

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

accraze commented Sep 30, 2016

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

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

same issue, any idea?

@jjgonecrypto
Copy link

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

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

dragosh pushed a commit to Backbase/bb-lp-cli that referenced this issue Oct 24, 2016
@danilosterrapid7
Copy link

danilosterrapid7 commented Oct 25, 2016

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 "[email protected]".

@danilosterrapid7
Copy link

danilosterrapid7 commented Oct 25, 2016

Also, it might be helpful
Issue: #84
Comment: #84 (comment)

@kurtommy
Copy link

kurtommy commented Nov 4, 2016

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

@obeyler
Copy link

obeyler commented Nov 6, 2016

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

npm install [email protected] worked for me on mac Sierra

@ghost
Copy link

ghost commented Nov 14, 2016

npm install [email protected] worked for me on mac Sierra works also but it's when you use you would have this kind of error

@thesafetylemur
Copy link

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

qiluo commented Apr 6, 2017

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

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

SimenB commented Apr 21, 2017

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

@yagudaev
Copy link

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: nano3labs/karma#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
Copy link

mwq27 commented May 14, 2017

Has anyone had any luck with this issue? I'm also on Sierra with [email protected] and [email protected].

@spiritson
Copy link

+1. Mac OS Sierra. Same issue

@trextroy
Copy link

trextroy commented Jul 6, 2017

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

@SimenB
Copy link

SimenB commented Jul 7, 2017

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

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

npm install [email protected] --save-dev
npm install [email protected] --save-dev

@trextroy
Copy link

trextroy commented Jul 31, 2017

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

scrubmx added a commit to scrubmx/jquery.loan-calculator that referenced this issue Aug 21, 2017
This commit solves the "Cannot start PhantomJS" on Mac OS Sierra.
Also, a package-lock.json file was created

karma-runner/karma-phantomjs-launcher#138 (comment)
totten added a commit to totten/civicrm-buildkit that referenced this issue Sep 12, 2017
Karma and PhantomJS are failing on OSX Sierra: karma-runner/karma-phantomjs-launcher#138

Before merging this, we should (at minimum) test to see if this installs
correctly on `ubu1204`.  If we could try another variant of OSX, that would
also be ideal.
@alexweissman
Copy link

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

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

pharlez added a commit to skroutz/selectorablium that referenced this issue Jan 10, 2018
Version fixes running PhantomJS process in Mac OS Sierra.
See karma-runner/karma-phantomjs-launcher#138.
@snimavat
Copy link

Updating to "[email protected]" fixed it for me

StyleT added a commit to StyleT/js-acl that referenced this issue Feb 16, 2018
francoismassart added a commit to keithamus/npm-scripts-example that referenced this issue Mar 7, 2018
This update allows me to run the tests on Mac OS Sierra…

See karma-runner/karma-phantomjs-launcher#138
@felipe-muner
Copy link

Same error for me =(

zhouzi pushed a commit to zhouzi/TheaterJS that referenced this issue Jun 4, 2018
* Upgrade `karma-phantomjs-launcher`

This fixes tests for Mac Os Sierra - [see this](karma-runner/karma-phantomjs-launcher#138).

* Add getCurrentSpeech() function & tests for it

* Update README with new getCurrentSpeech() function doc

* More solid version of getCurrentSpeech() function

* Add null test case for getCurrentSpeech()
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests