Repository: tauri-apps/tauri (language: rust)

Issue:
[bug] AppImage missing libwebkit2gtkinjectedbundle.so
### Describe the bug

Hi,

On Ubuntu 22.04.5

I bundled the a pristine project in AppImage and when running it, i get the following warning.

```sh
** (WebKitWebProcess:1195719): WARNING **: 10:14:55.371: Error loading the injected bundle (././/lib/x86_64-linux-gnu/webkit2gtk-4.1/injected-bundle/libwebkit2gtkinjectedbundle.so): ././/lib/x86_64-linux-gnu/webkit2gtk-4.1/injected-bundle/libwebkit2gtkinjectedbundle.so: cannot open shared object file: No such file or directory
```

On ubuntu /lib is a symlink to /usr/lib, and I believed cargo linked on /lib and that the appimage bundler only put things into /usr inside the appimage according to the doc https://v2.tauri.app/distribute/appimage/. I checked the AppImage /tmp mount and libwebkit2gtkinjectedbundle isnt there even in the /usr path.

I tried adding the .so manually, but I didnt manage to do it quickly and thus thought it would be worth writing an issue so that it is either fixed, or better documented about how to add .so to solve such problems.

### Reproduction

Ubuntu 22.04.5

```sh
# Install deps
sudo apt update
sudo apt install libwebkit2gtk-4.1-dev \
  build-essential \
  curl \
  wget \
  file \
  libxdo-dev \
  libssl-dev \
  libayatana-appindicator3-dev \
  librsvg2-dev

# Latest Rust stable 1.84.0 from rustup
# Nodejs 20 LTS from nodesource repositories

# Create new pristine project
cargo create-tauri-app
✔  Project name · tauri-app
✔ Identifier · com.tauri-app.app
✔ Choose which language to use for your frontend · TypeScript / JavaScript - (pnpm, yarn, npm, deno, bun)
✔ Choose your package manager · pnpm
✔ Choose your UI template · React - (https://react.dev/)
✔ Choose your UI flavor · TypeScript

# Run the AppImage
./src-tauri/target/release/bundle/appimage/tauri-app_0.1.0_amd64.AppImage

# And see
** (WebKitWebProcess:1195719): WARNING **: 10:14:55.371: Error loading the injected bundle (././/lib/x86_64-linux-gnu/webkit2gtk-4.1/injected-bundle/libwebkit2gtkinjectedbundle.so): ././/lib/x86_64-linux-gnu/webkit2gtk-4.1/injected-bundle/libwebkit2gtkinjectedbundle.so: cannot open shared object file: No such file or directory
```

Also I think there is sort of a caching thing because the first time at project creation I could choose vite or next and so on while now it selected vite without asking me what i wanted.

I've seen another issue and PR regarding a similar issue:
- https://github.com/tauri-apps/tauri/issues/6992
- https://github.com/tauri-apps/tauri/pull/6996/files

Maybe that can be of any help.


### Expected behavior

No Warning about missing .so, bundle the .so properly.

### Full `tauri info` output

```text
$ pnpm tauri info

> tauri-app@0.1.0 tauri /scratch/tauri-app
> tauri "info"


[✔] Environment
    - OS: Ubuntu 22.4.0 x86_64 (X64) (ubuntu on x11)
    ✔ webkit2gtk-4.1: 2.46.5
    ✔ rsvg2: 2.52.5
    ✔ rustc: 1.84.0 (9fc6b4312 2025-01-07)
    ✔ cargo: 1.84.0 (66221abde 2024-11-19)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-unknown-linux-gnu (default)
    - node: 20.18.1
    - pnpm: 10.0.0
    - npm: 10.8.2

[-] Packages
    - tauri 🦀: 2.2.3
    - tauri-build 🦀: 2.0.5
    - wry 🦀: 0.48.1
    - tao 🦀: 0.31.1
    - tauri-cli 🦀: 2.2.5
    - @tauri-apps/api : 2.2.0
    - @tauri-apps/cli : 2.2.5

[-] Plugins
    - tauri-plugin-opener 🦀: 2.2.5
    - @tauri-apps/plugin-opener : 2.2.5

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: React
    - bundler: Vite
```



Discussion / hints:
I just found a solution for myself, but I hope that could be solved by default.
The first attempts I tried did not work, but now it does

```json
    "linux": {
      "appimage": {
        "files": {
          "/usr/lib/x86_64-linux-gnu/webkit2gtk-4.1/injected-bundle/libwebkit2gtkinjectedbundle.so": "/lib/x86_64-linux-gnu/webkit2gtk-4.1/injected-bundle/libwebkit2gtkinjectedbundle.so"
	}	
      }
    }
```

Fix patch:
diff --git a/.changes/bundler-injectedbundle.md b/.changes/bundler-injectedbundle.md
new file mode 100644
index 000000000000..9f2305e85537
--- /dev/null
+++ b/.changes/bundler-injectedbundle.md
@@ -0,0 +1,5 @@
+---
+tauri-bundler: 'patch:bug'
+---
+
+Fixed an issue that caused the compiled AppImage to miss webkitgtk's internal `libwebkit2gtkinjectedbundle.so` file.
diff --git a/crates/tauri-bundler/src/bundle/linux/appimage.rs b/crates/tauri-bundler/src/bundle/linux/appimage.rs
index 87aa238eb1f4..3d039605dfcb 100644
--- a/crates/tauri-bundler/src/bundle/linux/appimage.rs
+++ b/crates/tauri-bundler/src/bundle/linux/appimage.rs
@@ -141,7 +141,7 @@ pub fn bundle_project(settings: &Settings) -> crate::Result<Vec<PathBuf>> {
   for file in [
     "WebKitNetworkProcess",
     "WebKitWebProcess",
-    "libwebkit2gtkinjectedbundle.so",
+    "injected-bundle/libwebkit2gtkinjectedbundle.so",
   ] {
     for source in search_dirs.map(PathBuf::from) {
       // TODO: Check if it's the same dir name on all systems


Test patch: