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

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

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Reactions: 127
  • Comments: 76 (25 by maintainers)

Commits related to this issue

Most upvoted comments

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

Workaround which worked for me

OS: Ubuntu 24.04.1 LTS x86_64 Kernel: 6.8.0-51-generic

  1. open file /etc/apt/sources.list
  2. insert new line deb http://archive.ubuntu.com/ubuntu jammy main universe
  3. sudo apt update
  4. sudo apt upgrade
  5. sudo apt install libwebkit2gtk-4.0-dev
  6. SUGGESTION remove/comment inserted line in /etc/apt/sources.list

Have you already solved this bug?

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

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.

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

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.

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

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

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

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.

This reports missing dependencies in Ubuntu 24.04.2:

The following packages have unmet dependencies:
 libwebkit2gtk-4.0-dev : Depends: libwebkit2gtk-4.0-37 (= 2.36.0-2ubuntu1) but 2.48.0-0ubuntu0.22.04.1 is to be installed
                         Depends: gir1.2-webkit2-4.0 (= 2.36.0-2ubuntu1) but it is not going to be installed
                         Depends: libjavascriptcoregtk-4.0-dev (= 2.36.0-2ubuntu1) but 2.48.0-0ubuntu0.22.04.1 is to be installed
E: Unable to correct problems, you have held broken packages.

(This affects other applications too. I came to this thread looking for a fix for this issue with typecatcher.)

On Ubuntu 24 works like a charm

🚀 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.

@mdeniz63 The solution is really like a band aid I would say because you have to convince users to use an older repository.

I just ran into this issue while trying to test a Tauri app on a fresh new Ubuntu virtual machine. This issue seems quite a valid concern for developers choosing Tauri as a distribution platform for their software.

To be honest, there’s no fix actually to this issue.

I think there is something the Tauri team (and community!) could help with though: documenting those pitfalls, and workarounds.

Example, on the current debian distribution page, no mention are made regarding:

  • backward compatibility
  • how libwebkit may be accessible for some distros or not
  • what developers should do with it?
    • is it possible to build for an older platform?
    • how to tell users about it? should we distribute different binaries?
    • should developers just target modern distros?
    • should developers target for snap/appimages/flatpaks instead? If yes, are there downsides?
  • are there workarounds? is it possible to ask users to install those older libwebkitgtk (via some other sources) and hope for things to work?
  • is there something in the long run that the Tauri team can do to support more platforms at once?
  • etc

I get it, Linux development is a freaking mess (and not only with Tauri), so let’s make people aware of it and attempt to provide solutions? :]

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

meet the same error in debian11 with testing branch

@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”)

I’ll add that instead of installing webkit2gtk in arch linux, you installed webkit2gtk-4.1, and if you installed webkit2gtk, you’ll get the same error

The long term solution that tauri is working to achieve is to ditch webkit altogether for verso aka servo

There’s a solution to this problem, number 1 is to distribute AppImages, they work everywhere

Number 2 is to have both a tauri 1 and tauri 2 codebase, but I don’t think that’s a great solution, or even a good solution

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'

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.