DevToys-app/DevToys · critical · DllNotFoundException

WebKitGTK could not be found. Please verify that the package

Error message

WebKitGTK could not be found. Please verify that the package 'libwebkitgtk-6.0-4' is installed on the operating system and retry.

What it means

Thrown as a DllNotFoundException by DevToys.Linux BlazorWebView.CreateWebView when accessing the WebView's WebContext throws (the Giraffe/Gtk bindings return null or crash when the native WebKitGTK library is not present). It is a translated, user-facing error that names the exact missing native package: libwebkitgtk-6.0-4. Without this native dependency the Linux BlazorWebView cannot construct a web view, so the whole UI shell fails to start.

Source

Thrown at src/app/dev/platforms/desktop/DevToys.Linux/Components/BlazorWebView/BlazorWebView.cs:200

    }

    private void MessageReceived(Uri uri, string message)
    {
        _webViewManager?.MessageReceivedInternal(uri, message);
    }

    private WebView CreateWebView()
    {
        var webView = new WebView();

        try
        {
            Guard.IsNotNull(webView
                .WebContext); // this might be null or crash when trying to access the WebContext property.
        }
        catch (Exception e)
        {
            throw new DllNotFoundException(
                "WebKitGTK could not be found. Please verify that the package 'libwebkitgtk-6.0-4' is installed on the operating system and retry.");
        }

        // Make web view transparent
        webView.SetBackgroundColor(new RGBA { Red = 255, Blue = 0, Green = 0, Alpha = 0 });

        // Initialize some basic properties of the WebView
        Settings webViewSettings = webView.GetSettings();
        webViewSettings.EnableDeveloperExtras = _enabledDeveloperTools;
        webViewSettings.JavascriptCanAccessClipboard = true;
        webViewSettings.EnableBackForwardNavigationGestures = false;
        webViewSettings.MediaPlaybackRequiresUserGesture = false;
        webViewSettings.HardwareAccelerationPolicy = HardwareAccelerationPolicy.Never; // https://github.com/DevToys-app/DevToys/issues/1234
        webView.SetSettings(webViewSettings);

        UserContentManager userContentManager = webView.GetUserContentManager();

        // Handle messages.

View on GitHub (pinned to 7e12df8448)

Solutions

  1. Install the native package: Debian/Ubuntu `sudo apt install libwebkitgtk-6.0-4`, Fedora `sudo dnf install webkitgtk6.0`, Arch `sudo pacman -S webkitgtk-6.0`.
  2. Verify the install with `ldconfig -p | grep webkitgtk-6.0` or by checking the file exists under /usr/lib.
  3. If on an older distro, upgrade to one shipping WebKitGTK 6.0 (GTK4 line), since the code targets the 6.0 API.
  4. For packaging (deb/rpm/Flatpak), declare libwebkitgtk-6.0-4 as a runtime dependency.
  5. Re-run the app; if it still fails, run with WEBKIT_DEBUG=1 / check stderr for the native load error.

Example fix

// before — native load failure surfaces as a raw null/crash inside new WebView()

// after — probe the native library before constructing the WebView and give an actionable message
using System.Runtime.InteropServices;

if (!NativeLibrary.TryLoad("webkitgtk-6.0", out _))
{
    throw new DllNotFoundException(
        "WebKitGTK could not be found. Please verify that the package " +
        "'libwebkitgtk-6.0-4' is installed on the operating system and retry.");
}
var webView = new WebView();
Guard.IsNotNull(webView.WebContext);
Defensive patterns

Strategy: try-catch

Validate before calling

using System.Runtime.InteropServices;

bool WebKitGtk6Available() =>
    NativeLibrary.TryLoad("webkitgtk-6.0", out _) ||
    NativeLibrary.TryLoad("libwebkitgtk-6.0.so.4", out _) ||
    NativeLibrary.TryLoad("libwebkitgtk-6.0.4", out _);

if (!WebKitGtk6Available())
{
    // show install instructions instead of crashing during WebView construction
    return;
}

Try / catch

try
{
    var webView = new WebView();
    Guard.IsNotNull(webView.WebContext);
    // ... proceed with CreateWebView body
}
catch (DllNotFoundException ex) when (ex.Message.Contains("WebKitGTK"))
{
    // surface the actionable install instruction (libwebkitgtk-6.0-4) to the user
    throw;
}

Prevention

When it happens

Trigger: Running the Linux desktop build on a distribution where libwebkitgtk-6.0-4 (the WebKitGTK 6.0 / GTK4 bindings) is not installed; only the legacy libwebkit2gtk-4.x (WebKit2 GTK3) is present; the native library is present but for the wrong architecture; the library exists but a transitive dependency (gtk4, libsoup3) is missing causing WebContext access to throw.

Common situations: Fresh Linux/minimal-container install without GUI runtime deps; distro that ships only WebKitGTK 2.x; downstream repackaging that dropped the runtime dependency; Flatpak/Snap base missing the webkit2gtk-6.0 runtime.

Related errors


AI-assisted analysis of DevToys-app/DevToys@7e12df8448 (2026-08-13). Data as JSON: /api/errors/50643e1da521ebc0. Report an issue: GitHub.