tauri-apps/tauri

libwebkit2gtk-4.0 not available in Ubuntu 24 & Debian 13 repositories

happybeing opened this issue · 66 comments

Describe the bug

The Tauri v1 pre-requisite libwebkit2gtk-4.0-dev is not available in Ubuntu 24 repositories. This causes an error when installing the pre-requisites specified here, and when running cargo tauri dev on Ubuntu 24.

Note: libwebkit2gtk-4.1-dev is available but doesn't help with Tauri 1.

Reproduction

Run:

sudo apt update
sudo apt install libwebkit2gtk-4.0-dev \
    build-essential \
    curl \
    wget \
    file \
    libssl-dev \
    libgtk-3-dev \
    libayatana-appindicator3-dev \
    librsvg2-dev

reports:

E: Unable to locate package libwebkit2gtk-4.0-dev
E: Couldn't find any package by glob 'libwebkit2gtk-4.0-dev'

And cargo tauri dev:

The following warnings were emitted during compilation:

warning: javascriptcore-rs-sys@0.4.0: 

error: failed to run custom build command for `javascriptcore-rs-sys v0.4.0`

Caused by:
  process didn't exit successfully: `/home/mrh/src/safe-browser/awe/src-tauri/target/debug/build/javascriptcore-rs-sys-855dc84908b0218c/build-script-build` (exit status: 1)
  --- stdout
  cargo:rerun-if-env-changed=JAVASCRIPTCOREGTK_4.0_NO_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_PATH
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
  cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
  cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
  cargo:warning=
  pkg-config exited with status code 1
  > PKG_CONFIG_PATH=/home/mrh/.gvm/pkgsets/go1.15/global/overlay/lib/pkgconfig: PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 pkg-config --libs --cflags javascriptcoregtk-4.0 javascriptcoregtk-4.0 >= 2.24

  The system library `javascriptcoregtk-4.0` required by crate `javascriptcore-rs-sys` was not found.
  The file `javascriptcoregtk-4.0.pc` needs to be installed and the PKG_CONFIG_PATH environment variable must contain its parent directory.
  PKG_CONFIG_PATH contains the following:
      - /home/mrh/.gvm/pkgsets/go1.15/global/overlay/lib/pkgconfig
      - 

  HINT: you may need to install a package such as javascriptcoregtk-4.0, javascriptcoregtk-4.0-dev or javascriptcoregtk-4.0-devel.

warning: build failed, waiting for other jobs to finish...

Workaround

I worked around this by adding the following line to /etc/apt/sources.list:

deb http://gb.archive.ubuntu.com/ubuntu jammy main

Then doing:

sudo apt update
sudo apt install libwebkit2gtk-4.0-dev

IMPORTANT: it was recommended in this comment to undo the change to sources.list after installing to prevent problems with dependencies being deleted.

Expected behavior

no errors

Full tauri info output

[✘] Environment
    - OS: Ubuntu 24.4.0 X64
    ✘ webkit2gtk-4.0: not installed
      Visit https://tauri.app/v1/guides/getting-started/prerequisites to learn more about tauri prerequisites
    ✔ rsvg2: 2.58.0
    ✔ rustc: 1.78.0 (9b00956e5 2024-04-29)
    ✔ cargo: 1.78.0 (54d8815d0 2024-03-26)
    ✔ rustup: 1.27.0 (bbb9276d2 2024-03-08)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (environment override by RUSTUP_TOOLCHAIN)
    - node: 22.1.0
    - yarn: 1.22.5
    - npm: 10.7.0

[-] Packages
    - tauri [RUST]: 1.6.1
    - tauri-build [RUST]: 1.5.1
    - wry [RUST]: 0.24.7
    - tao [RUST]: 0.16.8
    - tauri-cli [RUST]: 1.5.11
    - @tauri-apps/api [NPM]: 1.5.3 (outdated, latest: 1.5.4)
    - @tauri-apps/cli [NPM]: 1.5.11 (outdated, latest: 1.5.12)

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../build
    - devPath: http://localhost:5173/
    - framework: Svelte
    - bundler: Vite

Stack trace

No response

Additional context

No response

Same problem.

Have you already solved this bug?

see Ubuntu 24.04 LTS: error while loading shared libraries: libwebkit2gtk-4.0.so.37

sudo nano /etc/apt/sources.list.d/ubuntu.sources

add this as it shows:
jammy
jammy-security

then

sudo apt update
sudo apt install libwebkit2gtk-4.0-dev

npm run tauri dev

for my development env, this woks

see Ubuntu 24.04 LTS: error while loading shared libraries: libwebkit2gtk-4.0.so.37

sudo nano /etc/apt/sources.list.d/ubuntu.sources

add this as it shows: jammy jammy-security

then

sudo apt update
sudo apt install libwebkit2gtk-4.0-dev

npm run tauri dev

for my development env, this woks

for end user, use sudo apt install libwebkit2gtk-4.0 should be ok after add jammy and jammy-security into /etc/apt/sources.list.d/ubuntu.sources

see Ubuntu 24.04 LTS: error while loading shared libraries: libwebkit2gtk-4.0.so.37
sudo nano /etc/apt/sources.list.d/ubuntu.sources
add this as it shows: jammy jammy-security
then

sudo apt update
sudo apt install libwebkit2gtk-4.0-dev

npm run tauri dev

for my development env, this woks

for end user, use sudo apt install libwebkit2gtk-4.0 should be ok after add jammy and jammy-security into /etc/apt/sources.list.d/ubuntu.sources

This is a bit dirty. It is recommended to restore /etc/apt/sources.list.d/ubuntu.sources to its original state after installing libwebkit2gtk-4.0-dev.

Otherwise there will be weird errors, this is the one I'm currently experiencing:

on kububtu,when Double-click the deb package, will install the deb using the QApt graphical interface by default (i.e. qapt-deb-installer)

Double-click google-chrome-stable_current_amd64.deb 125.0.6422.112. It will originally prompt a dependency unsatisfied error in the QApt interface, but it can actually be installed using apt or dpkg

after changing /etc/apt/sources.list.d/ubuntu.sources and apt update

Double-clicking google-chrome-stable_current_amd64.deb 125.0.6422.112 does not prompt a dependency not satisfied error in the QApt interface, but displays that many dependencies need to be deleted.

These dependencies are necessary for the system, including the desktop environment, desktop keyboard and mouse input devices, input methods, etc. Many contents and some installed software will be deleted.

According to actual test, using apt to install this deb will automatically change to use the package in the server without causing problems.
Therefore the bug should be caused by the QApt graphical interface installation (i.e. qapt-deb-installer)

In addition, dpkg -i has not been tested. I don’t know whether apt install -f is required and whether it will cause problems.

Your workaround doesn't work:

The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libdbus-glib-1-dev : Depends: libdbus-glib-1-2 (= 0.112-3) but 0.112-3build2 is to be installed
 librsvg2-dev : Depends: librsvg2-2 (= 2.54.5+dfsg-1ubuntu2.1) but 2.58.0+dfsg-1build1 is to be installed
                Depends: librsvg2-common (= 2.54.5+dfsg-1ubuntu2.1) but 2.58.0+dfsg-1build1 is to be installed
E: Unable to correct problems, you have held broken packages.

I tested also on Kali and there is a conflict with libjpegturbo0. So now, it is unable to use tauri on latest Ubuntu LTS / Kali

The workaround in the OP worked on a clean Ubuntu 24.04.

The workaround in the OP worked on a clean Ubuntu 24.04.

cat /etc/apt/sources.list # on kubuntu24.04, it saids:
# Ubuntu sources have moved to /etc/apt/sources.list.d/ubuntu.sources

might who “Packaging these dependencies from ubuntu22.04 for installation on ubuntu24.04, and distinguishing between non-dev and dev versions “ can solve this problem?

Not functional on Debian Testing (Trixie) / Unstable (sid), the package is not added to the repositories.

Installing libwebkit2gtk-4.0-dev from Stable is not possible: it breaks the majority of already installed packages.

It's pretty much a show-stopper, there's no workaround atm.

I'm thinking of switching my project to Tauri 2.0 beta right now so that it uses webkit2gtk-4.1, and compatible with Ubuntu 24.04+, but I'm still not sure if it is worth it.

That will depend on the value of switching to you.

I've switched because I want to try some the new features and it seems good but I'm aware some issues I have could be with v2 beta, especially as I'm pushing she boundaries. But finding issues is the point of a beta, and my using it. No better time to get things fixed fast!

My app is though a demo not production so it won't be a disaster if I hit bugs, but so far it seems stable. The docs are a bit patchy and fluid, but the support I've had more than make up for that.

I don't see 4.1 in my Ubuntu 20.04 VM. Does that mean it's not possible for the same binary to support both 20.04 and 24.04?

I'm trying to think of workarounds I could do... maybe a shim script that launches either a 4.0-linked binary or a 4.1-linked binary after probing for libraries? It might work with Tauri's deb bundler, with some creativity, or I could hack around it.

But if that means simultaneously building for both Tauri 1.x and 2.x it would be too much effort. Unless 2.x has a compromise between deb and AppImage where I can install systemd services and have post-install and pre-remove scripts, but also bundle WebKit.

@ReactorScram I built on Ubuntu 24 after using the fix from the OP and in very early testing people found that the following worked:

  • .deb on Ubuntu 22.04 after 'sudo apt --fix-broken install`
  • .deb on Ubuntu 22.04 (no extras)
  • .deb on Ubuntu 23.04 (no tweaks) 🥳
  • .rpm converted to .deb running on Mint 🎉 (after turning the user off and on again 😆)

The following did not work:

  • AppImage on Ubuntu 23.04 (user reported "nothing happens")

If you built your app on 24.04 none of what you wrote is supposed to actually work due to glib not being backword compatible like this (basically the reason for "build on the oldest system you want to support"), so i'd be very careful with that approach.

@FabianLars that's exactly what I expected yet those are the facts! 🤷‍♂️

... so far.

🚀 Switching to v2.0 totally resolved it for me on Debian since libwebkit2gtk-4.1-dev is already added to the Testing and Unstable repositories.

meet the same error in debian11 with testing branch

This is preventing our C++ library (used by our Tauri v1 app) from using C++23 features, since C++23 requires Ubuntu 24.04.

i have seen same issue of ubuntu mate 24.04LTS, sudo apt install libwebkit2gtk-4.0-dev
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
E: Unable to locate package libwebkit2gtk-4.0-dev
E: Couldn't find any package by glob 'libwebkit2gtk-4.0-dev'. so i installed sudo apt install libwebkit2gtk-4.1-dev after that i am getting error error: failed to run custom build command for javascriptcore-rs-sys v0.4.0

This unfortunately opens up a can of worms on long term sustainability.

  • Installing cross-version repo is not a solution or a viable workaround without messing up the OS libs.
  • Being dynamically linked to these libs, always ends up in situations where it either works with new or old, but not both.

Solutions

  1. Either tauri will need to support multiple simultaneous versions with cfg (OR)
  2. Figure out a mechanism to select the dependencies at runtime, and have a compatibility shim that it can work with multiple versions.
  3. Provide an opt-out to link everything statically on Linux. (This will somewhat defeat the purpose of tauri that it'll blow up the binary size, but atleast it will work and still be smaller than Electron and the likes). This should be less of an issue, if not entirely a non-issue in platforms like Windows, but will primarily affect Linux on a running basis each time there's a gtk webkit update along with OS distros.

I just started with Tauri and had to stop because of this exact issue.
Touching the sources is a no-go.

My vote would be to statically link everything that's required on Linux (if that's even possible). If we try to rely on installed webkit version it will always be broken for the majority of users. I am relatively happy with the state of things on Windows/Mac but will need to find another non-Tauri solution for my Linux users. Maybe this could be an optional Rust/Cargo feature so if some people are size-adverse they can keep it disabled?

The AppImage bundler kinda does that, right? But we aren't using it for Firezone because we need to install a systemd service, which is much easier with deb packages

see Ubuntu 24.04 LTS: error while loading shared libraries: libwebkit2gtk-4.0.so.37
sudo nano /etc/apt/sources.list.d/ubuntu.sources
add this as it shows: jammy jammy-security
then

sudo apt update
sudo apt install libwebkit2gtk-4.0-dev

npm run tauri dev

for my development env, this woks

for end user, use sudo apt install libwebkit2gtk-4.0 should be ok after add jammy and jammy-security into /etc/apt/sources.list.d/ubuntu.sources

I didn't have this problem when I installed this library before upgrading to the unstable branch of Debian,
but due to problems I had to reinstall it, after upgrading to the unstable branch I can't install this library anymore,
maybe using stable repositories will help. 📝

see Ubuntu 24.04 LTS: error while loading shared libraries: libwebkit2gtk-4.0.so.37
sudo nano /etc/apt/sources.list.d/ubuntu.sources
add this as it shows: jammy jammy-security
then

sudo apt update
sudo apt install libwebkit2gtk-4.0-dev

npm run tauri dev

for my development env, this woks

for end user, use sudo apt install libwebkit2gtk-4.0 should be ok after add jammy and jammy-security into /etc/apt/sources.list.d/ubuntu.sources

I didn't have this problem when I installed this library before upgrading to the unstable branch of Debian, but due to problems I had to reinstall it, after upgrading to the unstable branch I can't install this library anymore, maybe using stable re
positories will help. 📝

Controversial decision

Add repos: deb http://deb.debian.org/debian/ bookworm main contrib non-free : apt edit-sources & Save
Save & Exit, update ur repos apt update & install lib apt install libwebkit2gtk-4.0-dev

Haven't noticed any problems afterwards, but I would delete old repositories after installation to avoid mishaps

image
image

Well, I'm driving Ubuntu 24.04 as well. I came here because of the problem. In reading the suggestions, I thought there had to be a cleaner way (new application). I used the bash installer for the v2 app. No need to change the sources. I still had to install some libs, but nothing that wasn't in v24.04. I know this doesn't help the v1 developers.

Well, I'm driving Ubuntu 24.04 as well. I came here because of the problem. In reading the suggestions, I thought there had to be a cleaner way (new application). I used the bash installer for the v2 app. No need to change the sources. I still had to install some libs, but nothing that wasn't in v24.04. I know this doesn't help the v1 developers.

Interestingly, I had a similar problem on the second version.

On Ubuntu 24 works like a charm

system info:

root@e9ec04e224d9:/workspace/aa/tauri-app/src-tauri# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu Noble Numbat (development branch)
Release:        24.04
Codename:       noble

run the command:

apt install libwebkit2gtk-4.0-dev \
    build-essential \
    curl \
    wget \
    file \
    libssl-dev \
    libgtk-3-dev \
    libayatana-appindicator3-dev \
    librsvg2-dev -y

the error is below:

Reading state information... Done
E: Unable to locate package libwebkit2gtk-4.0-dev
E: Couldn't find any package by glob 'libwebkit2gtk-4.0-dev'

After updating to tauri v2, I no longer have any issues on ubuntu 24. So we have resorted to updating our app fully from V1 to V2

Had the same issue, installed libwebkit2gtk-4.1-dev with sudo apt install libwebkit2gtk-4.1-dev. It worked like a charm!

This issue most probably no longer applies since tauri v2 is now table

Is v1 officially deprecated and out of support? In this case the issue would be irrelevant.

deprecated? yes
out of support? No

with the general state of linux support (in tauri etc) i have to say though that i doubt this issue will get properly solved.

Okay, maybe then this issue needs to be acknowledged in the Docs and the only solution to be is to upgrade to v2. And we can close this issue.

Any docs change should also mention the reverse issue (dropping support for CentOS etc). Something like

Tauri v1 requires libwebkit2gtk-4.0.so

  • Supported in Fedora 21, CentOS 7
  • Supported in Ubuntu 15.04, dropped in 24.04

Tauri v2 requires libwebkit2gtk-4.1.so

  • Supported in Fedora 37
  • Not supported in any released CentOS
  • Supported in Ubuntu 22.04, Debian Bookworm

deprecated? yes out of support? No

with the general state of linux support (in tauri etc) i have to say though that i doubt this issue will get properly solved.

I thought tauri (in future) would actually move to verso instead of libwebkitgtk on linux at least

Also, what are the real possible alternatives of webkitgtk2 for linux

I also think webkitgtk2 in itself, isn't that great either (good performance issues in my app + unfired events etc)

Yes, we want an alternative to webkitgtk but this is irrelevant for this issue because a) it needs a lot of time and b) it would not be backported to v1 (and probably not to v2 either)

(Posting in case someone else ran into the same problem and needed a quick "No it's impossible")

There's no way to get a v1 and a v2 project into the same workspace, right?
I'm getting errors from the dependency resolver, even if I use feature flags to disable my Tauri dep, saying that it can't have two different versions of a crate linking to a native lib like webkit2gtk

We're looking at keeping Ubuntu 20.04 support for another few months so it Would Be Nice if the v1 project could stay in our workspace, but it might just be dropped

It's indeed not directly possible to mix v1 and v2 in the same workspace without feature flags (at which point i'd personally just remove it from the workspace)

And How to build tauri2.0 in Debian 11?

Debian 11 doesn't have webkitgtk 4.1 so you can only build it inside docker or something like this but that built app will likely not run on debian 11.

Please help me. I try to install deb app
Screenshot from 2024-11-07 11-53-43

The error:
nginx@Inspiron-7472:~$ sudo apt-get install libwebkit2gtk-4.1-0
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libwebkit2gtk-4.1-0
E: Couldn't find any package by glob 'libwebkit2gtk-4.1-0'
E: Couldn't find any package by regex 'libwebkit2gtk-4.1-0'

@alicard What's the distro version you're trying to install it on? Like we said above, Debian 11 and below and Ubuntu 20.04 and below do not have the webkitgtk version we need for Tauri v2.

hey, are you thinking to release an fix for this or we still have to play with an workarounds? :)

hey, are you thinking to release an fix for this or we still have to play with an workarounds? :)

Most probably there will be no fix, because tauri v1 is kinda like deprecated now

Deprecated may be a bit harsh (or maybe not since I said the same above...) but I also don't expect us to fix this / add a workaround at this point tbh.

We wouldn't turn down any community contributions of course but I don't expect to see any.

I still don't know if it is even technically possible to reasonably solve this (not talking about completely replacing 4.0 with 4.1 in v1 because that makes no sense).

does the end user have to run sudo apt install libwebkit in order to open a tauri desktop app?

Depends. The AppImage just works ™️

The .deb will either be installed via sudo apt install ./myapp.deb or sudo dpkg -i ./myapp.deb && sudo apt-get -f install (or whatever other commands there are)

The .rpm will typically be installed via sudo dnf install ./myapp.rpm. sudo rpm -i ./myapp.rpm behaves like dpkg above and won't install dependencies but i don't know the exact command to get the deps, maybe also just sudo dnf install.

So yes, they need to run sudo apt install, but for the app itself. They don't have to install webkitgtk or other deps by hand.

i wasn't clear in my comment which is why it was marked off topic, i'm not talking about installing the app itself, but about about installing libwebkitgtk. what if the system doesn't have libwebkitgtk preinstalled?
does AppImage package a standalone libwebkitgtk binary for the app to use?

is it possible to package a standalone libwebkitgtk binary if the app is bundled in snap or flatpak?

i understood your question and my answer did contain this. I have to admit though that i lost focus on the topic when trying to remember the install commands.

The AppImage just works ™️

It just works because it bundles all of the dependencies, including webkitgtk inside.

The .deb will either be installed via sudo apt install ./myapp.deb or sudo dpkg -i ./myapp.deb && sudo apt-get -f install (or whatever other commands there are)

The first variant will install missing system dependencies. The second one does it explicitly because dpkg can't do it.
Same for the rpm/dnf variant below.

is it possible to package a standalone libwebkitgtk binary if the app is bundled in snap or flatpak?

If you follow our docs on those, yes.