Snapped application won't start for Nvidia graphic card

Hello,
I have managed to package a Qt based application somewhat successfully but it seems it won’t start on my laptop with Nvidia driver.
I have tried on live Ubuntu usb and it starts, aswell on another AMD-based laptop.

You can see the errors from the log:

libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
failed to acquire GL context to resolve capabilities, using defaults…
XmbTextListToTextProperty result code -2
XmbTextListToTextProperty result code -2
Failed to create OpenGL context for format QSurfaceFormat(version 2.0, options QFlagsQSurfaceFormat::FormatOption(), depthBufferSize 24, redBufferSize -1, greenBufferSize -1, blueBufferSize -1, alphaBufferSize -1, stencilBufferSize 8, samples -1, swapBehavior QSurfaceFormat::SwapBehavior(DoubleBuffer), swapInterval 1, profile QSurfaceFormat::OpenGLContextProfile(NoProfile))
Aborted

I tried adding the path mentioned in the helpers, from snappy playpen:

# Workaround in snapd for proprietary nVidia drivers mounts the drivers in
# /var/lib/snapd/lib/gl that needs to be in LD_LIBRARY_PATH
# Without that OpenGL using apps do not work with the nVidia drivers.
# Ref.: https://bugs.launchpad.net/snappy/+bug/1588192
append_dir LD_LIBRARY_PATH /var/lib/snapd/lib/gl

I am using Nvidia driver 430.09.
Distribution: KDE Neon 5.16 which is based off Ubuntu 18.04
Arch: AMD64.

Any help is much appreciated.

Can you share the snapcraft.yaml so we can debug it?

1 Like

So I just managed to fix it a minute ago, with uninstalling the drivers I installed manually and doing a sudo ubuntu-drivers autoinstall

Here is my snapcraft.yaml file

name: cumulus-qt
version: 4.2.1
summary: Weather viewing application
description: |
  Test description
confinement: devmode
base: core18
grade: stable

parts:
  cumulus-qt:
    plugin: dump
    source: .
    stage-packages:
        - libgl1
        - libgl1-mesa-glx
        - libgl1-mesa-dri
        - libglu1-mesa
        - libfreetype6
        - libpng16-16
        - libfontconfig1
        - libxi6        
        - xkb-data

apps:
  cumulus-qt:
    command: Cumulus.sh -i snap-version
    environment:
      QT_XKB_CONFIG_ROOT: $SNAP/usr/share/X11/xkb
      LD_LIBRARY_PATH: $SNAP/lib:$LD_LIBRARY_PATH
      QML_IMPORT_PATH: $SNAP/qml
      QML2_IMPORT_PATH: $SNAP/qml
      QT_PLUGIN_PATH: $SNAP/plugins
      QT_QPA_PLATFORM_PLUGIN_PATH: $SNAP/plugins/platforms
    plugs: [opengl, x11, desktop, network, home]

Btw, does it matter if I set the environment variables here or in my script file (Cumulus.sh file)?
Thanks.

perhaps this helps ?

https://github.com/plars/stellarium-snap/pull/2/files

(setting LIBGL_DRIVERS_PATH to point to the right path for nvidia)

1 Like

At this moment I would like to avoid uninstalling/reinstalling drivers but I integrated your code into my startup script so maybe will see it in the future. I have a lot of work to do and want to avoid breaking my system :smiley:.

Thanks a lot though, your input is very much appreciated.

2 posts were split to a new topic: Nvidia libraries not accessible inside snaps