karma-phantomjs-launcher icon indicating copy to clipboard operation
karma-phantomjs-launcher copied to clipboard

Windows 10 Bash (WSL)

Open ghost opened this issue 8 years ago • 22 comments

I wouldn't expect this to be supported, but wanted to leave a note that I spent a couple hours trying to get karma / phantom running headless on Windows Ubuntu bash (WSL) and received the "could not launch Phantom Browser" error. I followed the recommended steps of installing the additional libraries, but to no effect. Looking at one of the other comments, I did see that someone resolved their issue not just with the 127.0.0.1 hostname fix, but also with the loopback. In WSL, the settings seem to have a unique way of working with ifconfig, so that may be an issue. Anyway, feel free to close this as unsupported if appropriate.

ghost avatar Jun 06 '16 00:06 ghost

having the same issue... Again, it could be windows bash issue rather than the launcher. This is what I get

INFO [karma]: Karma v0.12.37 server started at http://localhost:9018/ INFO [launcher]: Starting browser PhantomJS ERROR [phantomjs.launcher]: PhantomJS has crashed. Please read the bug reporting guide at http://phantomjs.org/bug-reporting.html and file a bug report.

ERROR [launcher]: Cannot start PhantomJS

INFO [launcher]: Trying to start PhantomJS again (1/2). ERROR [phantomjs.launcher]: PhantomJS has crashed. Please read the bug reporting guide at http://phantomjs.org/bug-reporting.html and file a bug report.

ERROR [launcher]: Cannot start PhantomJS

INFO [launcher]: Trying to start PhantomJS again (2/2). ERROR [phantomjs.launcher]: PhantomJS has crashed. Please read the bug reporting guide at http://phantomjs.org/bug-reporting.html and file a bug report.

ERROR [launcher]: Cannot start PhantomJS

ERROR [launcher]: PhantomJS failed 2 times (cannot start). Giving up. Warning: Task "karma:continuous" failed. Use --force to continue.

Aborted due to warnings.

Voxis avatar Aug 09 '16 20:08 Voxis

Can you start PhantomJS by itself? If not this issue should be filed on the issue tracker of PhantomJS.

dignifiedquire avatar Aug 10 '16 14:08 dignifiedquire

@dignifiedquire Right. So I tried PhantomJS with their quick start page

Please look at the screenshot, I assume this shows PhantomJS works on my machine. image

I think I need to do a minimal test on karma's phantomjs launcher


Update: I did a minimal test with karma init, chose PhantomJS. And saw the above error.

Voxis avatar Aug 10 '16 15:08 Voxis

@Voxis yes looks like it's working by its own :)

dignifiedquire avatar Aug 10 '16 15:08 dignifiedquire

I too am experiencing the issue above. I can run PhantomJS by itself, but too see the same issue as Voxis when running via karma-phantomjs-launcher. Any work work around found?

rsteen avatar Aug 11 '16 19:08 rsteen

I'm also experiencing the same issue. However, I started karma with the browsers option empty, then manually ran PhantomJS to hit http://localhost:9876/, and it crashed just the same. I doubt it's an issue with the launcher specifically.

morrisallison avatar Aug 13 '16 03:08 morrisallison

Anything new here? I got this error:

10 10 2016 14:49:23.697:INFO [karma]: Karma v0.13.22 server started at http://localhost:9876/
10 10 2016 14:49:23.711:INFO [launcher]: Starting browser PhantomJS
10 10 2016 14:49:23.784:ERROR [phantomjs.launcher]: /mnt/c/Projekte/my-project/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory

10 10 2016 14:49:23.792:ERROR [launcher]: Cannot start PhantomJS

10 10 2016 14:49:23.804:INFO [launcher]: Trying to start PhantomJS again (1/2).
10 10 2016 14:49:23.858:ERROR [phantomjs.launcher]: /mnt/c/Projekte/my-project/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory

10 10 2016 14:49:23.863:ERROR [launcher]: Cannot start PhantomJS

10 10 2016 14:49:23.871:INFO [launcher]: Trying to start PhantomJS again (2/2).
10 10 2016 14:49:23.927:ERROR [phantomjs.launcher]: /mnt/c/Projekte/my-project/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory

10 10 2016 14:49:23.932:ERROR [launcher]: Cannot start PhantomJS

10 10 2016 14:49:23.935:ERROR [launcher]: PhantomJS failed 2 times (cannot start). Giving up.

npm ERR! Linux 3.4.0+
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "test"
npm ERR! node v4.4.2
npm ERR! npm  v3.10.6
npm ERR! code ELIFECYCLE
npm ERR! [email protected] test: `npm run build && node_modules/.bin/karma start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] test script 'npm run build && node_modules/.bin/karma start'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the my-project package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     npm run build && node_modules/.bin/karma start
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs my-project
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls my-project
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /mnt/c/Projekte/my-project/npm-debug.log

Chris2011 avatar Oct 10 '16 12:10 Chris2011

I already did a "npm install phantomjs phantomjs-prebuild --save" but got the same error.

Chris2011 avatar Oct 12 '16 11:10 Chris2011

Ok I fixed this bug while installing libfontconfig: https://github.com/ariya/phantomjs/issues/10904 but now I have the same bug with "phantomjs has crashed.". Now it is related to the Windows 10 bash too.

Chris2011 avatar Oct 12 '16 11:10 Chris2011

I am facing the same issue. Running phantomjs itself works. Tested it by doing a screenshot:

var page = require('webpage').create();
page.open('http://github.com/', function() {
  page.render('github.png');
  phantom.exit();
});

antitoxic avatar Oct 19 '16 11:10 antitoxic

How can we get more debug info?

antitoxic avatar Oct 19 '16 11:10 antitoxic

I've raised karma's logLevel to config.LOG_DEBUG and also set debug to true in a custom phantomjs launcher.

I see the command that phantomjs is run is:

/mnt/c/MY_RPOJECT/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs --load-images=true --remote-debugger-port=9000 --remote-debugger-autorun=yes /tmp/karma-69611971/capture.js

and the content of the generated capture.js is:

(function (phantom) {
  var page = require('webpage').create();

  page.onResourceError = function() {
    phantom.exit(1)
  }

  page.windowName = "my-window"
  page.settings.webSecurityEnabled = false


  page.onConsoleMessage = function () {
      console.log.apply(console, arguments)
  }
  function debugPage() {
    console.log('Launch the debugger page at http://localhost:9000/webkit/inspector/inspector.html?page=2')

    var debuggerWait = 15000
    console.log('Waiting ' + (debuggerWait / 1000) + ' seconds for debugger page to launch...')

    var launchPage = function () {
      console.log('Launching page http://localhost:9876/?id=9595785...')
      page.open('http://localhost:9876/?id=9595785')
    }

    setTimeout(launchPage, 15000)
  }
  debugPage()
}(phantom))

When I run the command above manually I get:

Launch the debugger page at http://localhost:9000/webkit/inspector/inspector.html?page=2
Waiting 15 seconds for debugger page to launch...
Launching page http://localhost:9876/?id=9595785...
Phantom::exit() called but not quitting in debug mode.

I don't see any useful data but may be you guys will.

antitoxic avatar Oct 19 '16 12:10 antitoxic

Further, digging in, I am running my tests in one terminal (npm run tests) and running /mnt/c/MY_RPOJECT/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs --load-images=true --remote-debugger-port=9000 --remote-debugger-autorun=yes /tmp/karma-69611971/capture.js in another terminal.

I am doing this because as far as I can see the script just connects to karma server.

This is the error that is shown in bash shell after phantomjs dies:

Segmentation fault (core dumped)

or this one in fish shell:

fish: “/mnt/c/…” terminated bysignal SIGSEGV (Address boundary error)

So if that's not completely wrong, than this error message might be interesting.

antitoxic avatar Oct 19 '16 12:10 antitoxic

Further info. I switched the --debug flag on phantomjs:

2016-10-19T15:31:16 [DEBUG] CookieJar - Created but will not store cookies (use option '--cookies-file=<filename>' to enable persistent cookie storage)
2016-10-19T15:31:16 [DEBUG] Set  "http"  proxy to:  "" : 1080
2016-10-19T15:31:16 [DEBUG] Phantom - execute: Configuration
2016-10-19T15:31:16 [DEBUG]      0 objectName : ""
2016-10-19T15:31:16 [DEBUG]      1 cookiesFile : ""
2016-10-19T15:31:16 [DEBUG]      2 diskCacheEnabled : "false"
2016-10-19T15:31:16 [DEBUG]      3 maxDiskCacheSize : "-1"
2016-10-19T15:31:16 [DEBUG]      4 diskCachePath : ""
2016-10-19T15:31:16 [DEBUG]      5 ignoreSslErrors : "false"
2016-10-19T15:31:16 [DEBUG]      6 localUrlAccessEnabled : "true"
2016-10-19T15:31:16 [DEBUG]      7 localToRemoteUrlAccessEnabled : "false"
2016-10-19T15:31:16 [DEBUG]      8 outputEncoding : "UTF-8"
2016-10-19T15:31:16 [DEBUG]      9 proxyType : "http"
2016-10-19T15:31:16 [DEBUG]      10 proxy : ":1080"
2016-10-19T15:31:16 [DEBUG]      11 proxyAuth : ":"
2016-10-19T15:31:16 [DEBUG]      12 scriptEncoding : "UTF-8"
2016-10-19T15:31:16 [DEBUG]      13 webSecurityEnabled : "true"
2016-10-19T15:31:16 [DEBUG]      14 offlineStoragePath : ""
2016-10-19T15:31:16 [DEBUG]      15 localStoragePath : ""
2016-10-19T15:31:16 [DEBUG]      16 localStorageDefaultQuota : "-1"
2016-10-19T15:31:16 [DEBUG]      17 offlineStorageDefaultQuota : "-1"
2016-10-19T15:31:16 [DEBUG]      18 printDebugMessages : "true"
2016-10-19T15:31:16 [DEBUG]      19 javascriptCanOpenWindows : "true"
2016-10-19T15:31:16 [DEBUG]      20 javascriptCanCloseWindows : "true"
2016-10-19T15:31:16 [DEBUG]      21 sslProtocol : "default"
2016-10-19T15:31:16 [DEBUG]      22 sslCiphers : "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-RC4-SHA:ECDHE-RSA-RC4-SHA:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:RC4-SHA:RC4-MD5"
2016-10-19T15:31:16 [DEBUG]      23 sslCertificatesPath : ""
2016-10-19T15:31:16 [DEBUG]      24 sslClientCertificateFile : ""
2016-10-19T15:31:16 [DEBUG]      25 sslClientKeyFile : ""
2016-10-19T15:31:16 [DEBUG]      26 sslClientKeyPassphrase : ""
2016-10-19T15:31:16 [DEBUG]      27 webdriver : ":"
2016-10-19T15:31:16 [DEBUG]      28 webdriverLogFile : ""
2016-10-19T15:31:16 [DEBUG]      29 webdriverLogLevel : "INFO"
2016-10-19T15:31:16 [DEBUG]      30 webdriverSeleniumGridHub : ""
2016-10-19T15:31:16 [DEBUG] Phantom - execute: Script & Arguments
2016-10-19T15:31:16 [DEBUG]      script: "/karma-temp-test-launcher.js"
2016-10-19T15:31:16 [DEBUG] Phantom - execute: Starting normal mode
2016-10-19T15:31:16 [DEBUG] WebPage - setupFrame ""
2016-10-19T15:31:16 [DEBUG] FileSystem - _open: ":/modules/fs.js" QMap(("mode", QVariant(QString, "r")))
2016-10-19T15:31:16 [DEBUG] FileSystem - _open: ":/modules/system.js" QMap(("mode", QVariant(QString, "r")))
2016-10-19T15:31:16 [DEBUG] FileSystem - _open: ":/modules/webpage.js" QMap(("mode", QVariant(QString, "r")))
Launch the debugger page at http://localhost:9000/webkit/inspector/inspector.html?page=2
Waiting 15 seconds for debugger page to launch...
Launching page http://localhost:9876/?id=9595785...
2016-10-19T15:31:31 [DEBUG] WebPage - updateLoadingProgress: 10
2016-10-19T15:31:31 [WARNING] QObject::connect: Cannot connect (null)::stateChanged(QNetworkSession::State) to QNetworkReplyHttpImpl::_q_networkSessionStateChanged(QNetworkSession::State)
2016-10-19T15:31:31 [DEBUG] WebPage - updateLoadingProgress: 30
2016-10-19T15:31:31 [DEBUG] WebPage - setupFrame "context"
2016-10-19T15:31:31 [DEBUG] WebPage - updateLoadingProgress: 30
2016-10-19T15:31:31 [WARNING] QObject::connect: Cannot connect (null)::stateChanged(QNetworkSession::State) to QNetworkReplyHttpImpl::_q_networkSessionStateChanged(QNetworkSession::State)
2016-10-19T15:31:31 [WARNING] QObject::connect: Cannot connect (null)::stateChanged(QNetworkSession::State) to QNetworkReplyHttpImpl::_q_networkSessionStateChanged(QNetworkSession::State)
2016-10-19T15:31:31 [DEBUG] WebPage - updateLoadingProgress: 33
2016-10-19T15:31:31 [DEBUG] WebPage - updateLoadingProgress: 37
2016-10-19T15:31:31 [DEBUG] WebPage - updateLoadingProgress: 40
2016-10-19T15:31:31 [DEBUG] WebPage - updateLoadingProgress: 43
2016-10-19T15:31:31 [DEBUG] WebPage - updateLoadingProgress: 46
2016-10-19T15:31:31 [DEBUG] WebPage - updateLoadingProgress: 48
2016-10-19T15:31:31 [DEBUG] WebPage - setupFrame ""
2016-10-19T15:31:31 [DEBUG] WebPage - updateLoadingProgress: 50
2016-10-19T15:31:31 [WARNING] QObject::connect: Cannot connect (null)::stateChanged(QNetworkSession::State) to QNetworkReplyHttpImpl::_q_networkSessionStateChanged(QNetworkSession::State)
2016-10-19T15:31:31 [DEBUG] WebPage - updateLoadingProgress: 100
2016-10-19T15:31:31 [DEBUG] CookieJar - Saved "io=xWNzfuTzqerWDXq8AAAB; domain=localhost; path=/socket.io/"
PhantomJS has crashed. 

antitoxic avatar Oct 19 '16 12:10 antitoxic

Have a very similar issue, but with Ruby/Poltergeist on Ubuntu for Windows 10. Maybe my debug output can help: https://gist.github.com/hartator/5a49360381dcdf47fc512f5fa1026b77

hartator avatar Nov 01 '16 07:11 hartator

Found a solution, the /run/lock directory was missing, just run mkdir -p /run/lock.

hartator avatar Nov 01 '16 21:11 hartator

Never mind, I think I've spoken too fast.

hartator avatar Nov 02 '16 00:11 hartator

There is a similar issue reported on the BashOnWindows

https://github.com/Microsoft/BashOnWindows/issues/903

moanrose avatar Dec 23 '16 11:12 moanrose

Is this still true? It is not possible to run tests on WSL?

brunofin avatar Apr 25 '18 07:04 brunofin

@brunofin It's been resolved since October: https://github.com/Microsoft/WSL/issues/903#issuecomment-338084071

mbland avatar Apr 25 '18 11:04 mbland

@mbland yes I see, I was running into another error, but I finally managed to make everything run, thanks.

brunofin avatar Apr 25 '18 11:04 brunofin