Skip to content
TheChatArchiveThe Chat Archive
chatgpt-4o-latest-20250326· OpenAIHugging Face LMArena Human Preference 140K

qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in "" This application failed…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with DeepSeekdeepseek-v3-0324’s answer.
  1. User

    qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in "" This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

  2. Assistant

    This error typically happens when you're attempting to run a Qt application, and it's failing to find the necessary platform plugin xcb on a Linux system. Here's a breakdown of what's going wrong and how to fix it.


    🔍 What Does This Error Mean?

    Qt uses platform plugins (like "xcb" for X11) to interface with the windowing system. If the application can't find the appropriate plugin, it can't launch.

    You’re seeing this error:

    qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
    This application failed to start because no Qt platform plugin could be initialized.
    

    ✅ Solutions

    Here are the most common ways to fix this issue:


    🔧 1. Install Required Dependencies (Linux)

    If you're on Ubuntu/Debian, install the dependencies:

    sudo apt update
    sudo apt install --reinstall libxcb-xinerama0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-shape0 libxcb-xfixes0
    

    Also, make sure general Qt dependencies are installed:

    sudo apt install qt5-default qtwayland5 libxkbcommon-x11-0
    

    For Fedora, use:

    sudo dnf install qt5-qtbase xcb-util xcb-util-image xcb-util-keysyms xcb-util-renderutil xcb-util-wm
    

    🛠 2. Set the QT_PLUGIN_PATH or Use QT_QPA_PLATFORM_PLUGIN_PATH

    If the plugin is installed but the program can't find it, you may need to manually set the plugin path:

    export QT_QPA_PLATFORM_PLUGIN_PATH=/path/to/Qt/plugins/platforms
    

    You can locate the path with:

    find / -name libqxcb.so 2>/dev/null
    

    Then use the directory where libqxcb.so is found as the plugin path.


    📦 3. Bundle Plugins with Application (for PyQt/PySide Apps or AppImage)

    If you're packaging your app or using an AppImage, ensure that the platforms directory with libqxcb.so is included in your distribution.

    Structure should look something like:

    your_app/
    ├── platforms/
    │   └── libqxcb.so
    ├── your_application_binary
    

    🐍 4. If You're Using PyQt5/PySide2 in Python

    Make sure pyqt5 is installed properly:

    pip install --upgrade pyqt5
    

    And ensure you have required system packages as listed in Step 1.


    🧽 5. Clear Environment Conflicts

    If $QT_PLUGIN_PATH or other Qt variables are incorrectly set, they may interfere:

    unset QT_QPA_PLATFORM_PLUGIN_PATH
    unset QT_PLUGIN_PATH
    

    Try running the application again.


    🧰 6. As a Last Resort: Reinstall Qt

    Sometimes a broken installation causes trouble. Try reinstalling:

    For Qt from your distro:

    sudo apt purge qt5-default qtbase5-dev
    sudo apt install qt5-default
    

    If you’re using a manually installed Qt:

    • Remove and reinstall through Qt Maintenance Tool or reinstall from the Qt Installer.

    🔄 Summary of Fixes

    ActionCommandUse When
    Install missing libssudo apt install ...On Debian/Ubuntu systems
    Set plugin pathexport QT_QPA_PLATFORM_PLUGIN_PATH=...When libqxcb.so isn't found
    Reinstall QtSee aboveIf all else fails

    If you tell me your operating system and how you installed or run your Qt app (manually, PyQt, AppImage, etc.), I can give more specific guidance.

  3. User

    NixOS

  4. Assistant

    Thanks for the clarification — since you're running NixOS, the fix here is different from other Linux distributions.


    🐧 Why This Happens on NixOS

    NixOS uses a unique package management system that makes runtime paths non-standard. Qt applications often fail with:

    qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
    

    Because the Qt environment has not been properly set up for execution inside a nix-shell, flake, or custom derivation.


    ✅ Solutions for NixOS

    ✅ 1. Use qt5.qtbase or qt6.qtbase in Your Shell/Derivation

    If you're developing or running something inside a nix-shell, make sure to include the Qt platform plugins.

    Example shell.nix:

    { pkgs ? import <nixpkgs> {} }:
    
    pkgs.mkShell {
      buildInputs = [
        pkgs.qt5.full             # or pkgs.qt6.full
        pkgs.qt5.qttools
        pkgs.xorg.libxcb
      ];
    
      shellHook = ''
        export QT_QPA_PLATFORM_PLUGIN_PATH=${pkgs.qt5.qtbase}/lib/qt-5/plugins/platforms
      '';
    }
    

    Or with Qt6:

    export QT_QPA_PLATFORM_PLUGIN_PATH=${pkgs.qt6.qtbase}/lib/qt-6/plugins/platforms
    

    ✅ 2. When Running a Binary, Use qtWrapper

    If you're packaging a binary or using a downloaded binary from somewhere outside of Nix, use a wrapper to inject the required environment:

    pkgs.makeWrapper pkgs.my-app-name \
      --set QT_QPA_PLATFORM_PLUGIN_PATH "${pkgs.qt5.qtbase}/lib/qt-5/plugins/platforms"
    

    This is usually done inside a derivation or flake, but you can simulate it manually like:

    env QT_QPA_PLATFORM_PLUGIN_PATH=$(nix eval --raw nixpkgs#qt5.qtbase)/lib/qt-5/plugins/platforms ./your-qt-app-binary
    

    ✅ 3. Use GSettings or wrapQtApp

    If you're making your own app derivation, wrap Qt apps with:

    wrapQtApp myApp
    

    In full example:

    { stdenv, wrapQtAppsHook, qt5, ... }:
    
    stdenv.mkDerivation {
      name = "my-qt-app";
      src = ./.;
    
      nativeBuildInputs = [ wrapQtAppsHook ];
    
      buildInputs = [ qt5.qtbase ];
    
      installPhase = ''
        mkdir -p $out/bin
        cp my-qt-app-binary $out/bin/
        wrapQtApp $out/bin/my-qt-app-binary
      '';
    }
    

    ✅ 4. Use Nix Flakes (devShells or apps)

    If you're using flakes, include the relevant Qt packages and automatically configure env using wrapQtApp.

    Minimal example:

    {
      description = "QT app shell";
    
      inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    
      outputs = { self, nixpkgs }: {
        devShells.default = nixpkgs.legacyPackages.x86_64-linux.mkShell {
          buildInputs = [
            nixpkgs.legacyPackages.x86_64-linux.qt5.full
          ];
    
          shellHook = ''
            export QT_QPA_PLATFORM_PLUGIN_PATH=${nixpkgs.legacyPackages.x86_64-linux.qt5.qtbase}/lib/qt-5/plugins/platforms
          '';
        };
      };
    }
    

    🧪 Test It

    Test with:

    echo $QT_QPA_PLATFORM_PLUGIN_PATH
    ls $QT_QPA_PLATFORM_PLUGIN_PATH
    

    You should see libqxcb.so in the output directory.


    🧾 Summary

    SituationFix
    Qt app in nix-shellInclude qt5.qtbase or qt6.qtbase, and set QT_QPA_PLATFORM_PLUGIN_PATH
    Qt app in derivationUse wrapQtApp
    Qt app flakeAdd Qt to devShells, set env vars, or use hook

    ✅ If you share how you're running the application — e.g., standalone binary, dev environment (nix-shell? flake?), or packaging it — I can show you the exact Nix expression or command to fix it.

  5. User

    Vivaldi

  6. Assistant

    Got it! You're trying to run Vivaldi on NixOS and getting this error:

    qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in ""
    This application failed to start because no Qt platform plugin could be initialized.
    

    This is a known issue when trying to run non-Nix-native Qt applications (like Vivaldi, which comes as a precompiled Chromium-based Qt app) on NixOS, due to missing dynamic Qt plugin paths in the Nix environment.


    ✅ ✅ Working Fix for Vivaldi on NixOS

    The easiest way to fix this is to install Vivaldi from Nixpkgs, not from the upstream .deb or from external binaries.


    🔁 Option 1: Use the Official Nixpkgs Package

    Vivaldi is available in nixpkgs, and has all dependencies properly wrapped.

    ✅ Install via nix-env:

    nix-env -iA nixpkgs.vivaldi
    

    or with nix profile (if you're using flakes):

    nix profile install nixpkgs#vivaldi
    

    💡 This version of Vivaldi is automatically wrapped with all necessary environment variables, including for libxcb and GTK.


    🧱 Option 2: Run Binary Manually with QT Plugin Path Fix

    If you must use the upstream .deb version of Vivaldi (not recommended on NixOS), you need to manually set up the Qt environment:

    Step-by-step:

    1. Find where libqxcb.so is (from qt5.qtbase):
    nix eval --raw nixpkgs#qt5.qtbase
    

    This will give you something like:

    /nix/store/xxxxxxxx-qtbase-5.x.x
    
    1. Then run Vivaldi with the environment variable set:
    QT_QPA_PLATFORM_PLUGIN_PATH=$(nix eval --raw nixpkgs#qt5.qtbase)/lib/qt-5/plugins/platforms ./vivaldi
    

    Or create a wrapper like:

    #!/usr/bin/env bash
    QT_QPA_PLATFORM_PLUGIN_PATH=$(nix eval --raw nixpkgs#qt5.qtbase)/lib/qt-5/plugins/platforms \
      /path/to/vivaldi "$@"
    

    Make it executable:

    chmod +x vivaldi-wrapper.sh
    

    Then run:

    ./vivaldi-wrapper.sh
    

    💡 You may also need to set LD_LIBRARY_PATH for libxcb and other dependencies if Vivaldi is missing them in its sandbox.


    🚨 Why This Happens

    • NixOS has no global FHS, so the dynamic linker can't find Qt plugins for binaries that expect them in standard locations.
    • System-packaged versions in Nixpkgs are wrapped with Qt/GTK variables, but third-party binaries are not.

    🧪 Bonus: Debug the Path Manually

    nix-shell -p qt5.qtbase --run 'echo $QT_QPA_PLATFORM_PLUGIN_PATH && ls $QT_QPA_PLATFORM_PLUGIN_PATH'
    

    You should see a path and libqxcb.so.


    ✅ Conclusion

    MethodRecommended?Notes
    ✅ Install Vivaldi from nixpkgs✅ Best optionFully compatible and wrapped
    ⚙️ Manually run or wrap upstream binary⚠️ OK but fragileMust manually supply plugin paths
    ❌ Use .deb without wrapping❌ Will failNixOS can't run FHS binaries unwrapped

    If you're using flakes or a custom shell to run Vivaldi, I can help you write a precise flake or shell environment to make it work.

    Let me know if you want:

    • A shell-friendly wrapper for manual Vivaldi installs.
    • A custom derivation for your own wrapped Vivaldi.
    • To fix other Qt apps with the same issue.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.