Phantomjs: set QT_QPA_PLATFORM env variable causes crash

Created on 3 Mar 2016  Â·  18Comments  Â·  Source: ariya/phantomjs

phantomjs-2.1.1-linux-x86_64

QT_QPA_PLATFORM=xcb phantomjs :(
This application failed to start because it could not find or load the Qt platform plugin "xcb".

Available platform plugins are: phantom.

Reinstalling the application may fix this problem.
PhantomJS has crashed. Please read the bug reporting guide at
http://phantomjs.org/bug-reporting.html and file a bug report.
[1] 6608 abort (core dumped) QT_QPA_PLATFORM=xcb phantomjs

stale

Most helpful comment

Exactly same issue, stuck for hours and find here, just tried QT_QPA_PLATFORM='' phantomjs then phantomjs works, currently we may use alias to fix this.(´_`)

I'm on latest Arch Linux, the Qt environment variables were automatically set by system.(Original QT_QPA_PLATFORM value is xcb)

All 18 comments

This is not supported. Don't setup environment variables. We static version of Qt, it contains only minimal plugins for PhantomJS functionality.

Maybe we should detect such environment variables before initializing Qt, and either arrange to ignore them, or fail to start with a message that makes clear that this is _not_ a bug.

@zackw Qt has a lot of environment variables. I know that in this case we should handle only QT_QPA_PLATFORM. But I don't like this idea. Sounds like a hack for me.

Another thing. I know that some users (and we) would like to move away from bundled QtBase to system provided. Perhaps we should just wait for it.

Exactly same issue, stuck for hours and find here, just tried QT_QPA_PLATFORM='' phantomjs then phantomjs works, currently we may use alias to fix this.(´_`)

I'm on latest Arch Linux, the Qt environment variables were automatically set by system.(Original QT_QPA_PLATFORM value is xcb)

Same here:

  • Archlinux latest
  • Frantic1048 solution works for me too

Thank you!

@Vitallium QT_QPA_PLATFORM=xcb is set by the system here, just installing phantomjs and running it fails.

npm test for whatever that is using phantomjs also fails.

@ChALkeR damn. Looks like we have to unset it in PhantomJS itself.

@Vitallium I believe that qputenv("QT_QPA_PLATFORM", ""); before https://github.com/ariya/phantomjs/blob/master/src/main.cpp#L45 should work (if that's the sole entrance point).

@ChALkeR qunsetenv is better. Feel free to create a pull request for that.

@Vitallium Indeed.

Sorry, I don't want to file pull requests without testing things, and I don't have time to build PhantomJS myself atm =), so no pull request from me for now. I could do this later, though, if it would still be needed. No idea when, though.

I got the same issue. Arch Linux here too.
unset QT_QPA_PLATFORM did it for now.
Thanks.

The same bug for me for phantomjs-2.1.1. Adding alias with unset environment variable works around, but not always.

Please fix it, it should be easy one-few line(s) fix.

I also have the issue. Thanks @JuHwon for the temporary fix.

Anyway, I just compiled new version of phantomjs from the source from master branch (with qt-5.6.1), works fine for me with QT_QPA_PLATFORM=xcb bin/phantomjs. No idea what actually could be changed... I can't try to build it from source from tag 2.1.1, because it requires qt-5.5, which is not installed in my computer).

@ariya when are you going to do next release, like 2.1.2 ?

@Vitallium After set QT_QPA_PLATFORM=offscreen, phantomjs 2.5.0-development can launch. Empty QT_QPA_PLATFORM not working.

$ env QT_QPA_PLATFORM='offscreen' bin/phantomjs -v
2.5.0-development

$ env QT_QPA_PLATFORM='' bin/phantomjs -v
QXcbConnection: Could not connect to display :0.0
PhantomJS has crashed. Please read the bug reporting guide at
<http://phantomjs.org/bug-reporting.html> and file a bug report.
[1]    7715 abort      env QT_QPA_PLATFORM='' bin/phantomjs -v

@leeight Do you use a pre-compiled version of PhantomJS or a compiled one? I compiled it and still get the error with/without the QT_QPA_PLATFORM env variable.

Due to our very limited maintenance capacity, we need to prioritize our development focus on other tasks. Therefore, this issue will be automatically closed (see #15395 for more details). In the future, if we see the need to attend to this issue again, then it will be reopened. Thank you for your contribution!

Same issue is happening for me, the following command fixes it (as a workaround):
env QT_QPA_PLATFORM='offscreen' phantomjs -v

Was this page helpful?
0 / 5 - 0 ratings

Related issues

qaDream77 picture qaDream77  Â·  4Comments

yisibl picture yisibl  Â·  5Comments

Snowlav picture Snowlav  Â·  3Comments

sinojelly picture sinojelly  Â·  3Comments

julmot picture julmot  Â·  5Comments