qt.qpa.plugin: Could not find the Qt platform plugin "xcb" in "" This application failed…
- 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.
- Assistant
This error typically happens when you're attempting to run a Qt application, and it's failing to find the necessary platform plugin
xcbon 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-xfixes0Also, make sure general Qt dependencies are installed:
sudo apt install qt5-default qtwayland5 libxkbcommon-x11-0For 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_PATHIf 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/platformsYou can locate the path with:
find / -name libqxcb.so 2>/dev/nullThen use the directory where
libqxcb.sois 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
platformsdirectory withlibqxcb.sois 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
pyqt5is installed properly:pip install --upgrade pyqt5And ensure you have required system packages as listed in Step 1.
🧽 5. Clear Environment Conflicts
If
$QT_PLUGIN_PATHor other Qt variables are incorrectly set, they may interfere:unset QT_QPA_PLATFORM_PLUGIN_PATH unset QT_PLUGIN_PATHTry 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-defaultIf you’re using a manually installed Qt:
- Remove and reinstall through Qt Maintenance Tool or reinstall from the Qt Installer.
🔄 Summary of Fixes
Action Command Use When Install missing libs sudo apt install ...On Debian/Ubuntu systems Set plugin path export QT_QPA_PLATFORM_PLUGIN_PATH=...When libqxcb.soisn't foundReinstall Qt See above If 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.
- User
NixOS
- 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.qtbaseorqt6.qtbasein Your Shell/DerivationIf 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
qtWrapperIf 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
wrapQtAppIf you're making your own app derivation, wrap Qt apps with:
wrapQtApp myAppIn 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 (
devShellsorapps)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_PATHYou should see
libqxcb.soin the output directory.
🧾 Summary
Situation Fix Qt app in nix-shellInclude qt5.qtbaseorqt6.qtbase, and setQT_QPA_PLATFORM_PLUGIN_PATHQt app in derivation Use wrapQtAppQt app flake Add 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. - User
Vivaldi
- 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
.debor 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.vivaldior 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
libxcband GTK.
🧱 Option 2: Run Binary Manually with QT Plugin Path Fix
If you must use the upstream
.debversion of Vivaldi (not recommended on NixOS), you need to manually set up the Qt environment:Step-by-step:
- Find where
libqxcb.sois (fromqt5.qtbase):
nix eval --raw nixpkgs#qt5.qtbaseThis will give you something like:
/nix/store/xxxxxxxx-qtbase-5.x.x- Then run Vivaldi with the environment variable set:
QT_QPA_PLATFORM_PLUGIN_PATH=$(nix eval --raw nixpkgs#qt5.qtbase)/lib/qt-5/plugins/platforms ./vivaldiOr 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.shThen run:
./vivaldi-wrapper.sh💡 You may also need to set
LD_LIBRARY_PATHforlibxcband 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
Method Recommended? Notes ✅ Install Vivaldi from nixpkgs✅ Best option Fully compatible and wrapped ⚙️ Manually run or wrap upstream binary ⚠️ OK but fragile Must manually supply plugin paths ❌ Use .deb without wrapping ❌ Will fail NixOS 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.
- Find where
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.