AvaloniaUI / Avalonia

Develop Desktop, Embedded, Mobile and WebAssembly apps with C# and XAML. The most popular .NET UI client technology
https://avaloniaui.net
MIT License
25.48k stars 2.21k forks source link

System.InvalidOperationException: Neither DBus nor GTK are available on the system #16078

Closed Hannes1909 closed 3 months ago

Hannes1909 commented 3 months ago

Describe the bug

Hi, I'm running NixOS unstable on Hyprland - when installing OpenUtau (built on Avalonia 11.0.4) and opening any FileBrowserDialog like "File --> Open/Save/Import Audio...." etc. it crashes with the error in title. Stacktrace:

Unhandled exception. System.InvalidOperationException: Neither DBus nor GTK are available on the system
   at Avalonia.X11.NativeDialogs.CompositeStorageProvider.EnsureStorageProvider()
   at Avalonia.X11.NativeDialogs.CompositeStorageProvider.OpenFilePickerAsync(FilePickerOpenOptions options)
   at OpenUtau.App.FilePicker.OpenFile(Window window, String titleKey, String startLocation, FilePickerFileType[] types) in /build/source/OpenUtau/FilePicker.cs:line 61
   at OpenUtau.App.FilePicker.OpenFile(Window window, String titleKey, FilePickerFileType[] types) in /build/source/OpenUtau/FilePicker.cs:line 53
   at OpenUtau.App.Views.MainWindow.OnMenuImportAudio(Object sender, RoutedEventArgs args) in /build/source/OpenUtau/Views/MainWindow.axaml.cs:line 298
   at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_0(Object state)
   at Avalonia.Threading.SendOrPostCallbackDispatcherOperation.InvokeCore()
   at Avalonia.Threading.DispatcherOperation.Execute()
   at Avalonia.Threading.Dispatcher.ExecuteJob(DispatcherOperation job)
   at Avalonia.Threading.Dispatcher.ExecuteJobsCore(Boolean fromExplicitBackgroundProcessingCallback)
   at Avalonia.Threading.Dispatcher.Signaled()
   at Avalonia.X11.X11PlatformThreading.CheckSignaled()
   at Avalonia.X11.X11PlatformThreading.RunLoop(CancellationToken cancellationToken)
   at Avalonia.Threading.DispatcherFrame.Run(IControlledDispatcherImpl impl)
   at Avalonia.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at Avalonia.Threading.Dispatcher.MainLoop(CancellationToken cancellationToken)
   at Avalonia.Controls.ApplicationLifetimes.ClassicDesktopStyleApplicationLifetime.Start(String[] args)
   at Avalonia.ClassicDesktopStyleApplicationLifetimeExtensions.StartWithClassicDesktopLifetime(AppBuilder builder, String[] args, ShutdownMode shutdownMode)
   at OpenUtau.App.Program.Run(String[] args) in /build/source/OpenUtau/Program.cs:line 77
   at OpenUtau.App.Program.Main(String[] args) in /build/source/OpenUtau/Program.cs:line 42

To Reproduce

NixOS Unstable, Hyprland. Install OpenUtau with home-manager like:

{ config, pkgs, ... }:

{
  home.packages = [
    pkgs.openutau
  ];
}

run it, open FileBrowserDialog / FilePicker.

Expected behavior

FilePicker opens as expected and lets me select a file to open/save to etc.

Avalonia version

11.0.4

OS

Linux

Additional context

Dependencies from nixpkgs It seems to work on a test VM with NixOS Stable Gnome (Boot upo ISO, Install, nix-shell -p OpenUtau), so it could be only related to Hyprland, maybe? Or some Nix-Packages/Dependencies for FilePicker I'm missing?

thevortexcloud commented 3 months ago

I imagine you are missing portal support for file pickers. You need something that implements them. I am guessing if you install something like flatpak it will probably bring in portal support with it. A quick search shows more portal libraries are available to also install on Nix. EG the GTK and the QT ones are available. There is also xdg-desktop-portal-hyprland.

kekekeks commented 3 months ago

1) Avalonia attempts to use xdg-desktop-portal DBUS protocol provided by any normal modern Linux distro 2) Avalonia attempts to load GTK using default library load path (which works with anything except for gobolinux and its spiritual followers)

If both of those fail, Avalonia will not be able to show the system file dialog.

Please, adjust your environment in a way that either (1) or (2) will be available.

Hannes1909 commented 3 months ago

Thanks for your replies, I was able to find a solution thanks to this upstream issue Moving my xdg-portal configuration from homemanager to /etc/nixos/configuration.nix did the trick.