tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
78.1k stars 2.31k forks source link

[bug] Mac Production Build by GitHub Action doesn't run (missing libssl and code sign) #9684

Closed HuakunShen closed 1 week ago

HuakunShen commented 1 week ago

Describe the bug

Question: Is there some dependency like pkg-config or openssl@3 need to be added to the GitHub Action?

1. Build Error

I could run and build the app locally but have problem building mac app with GitHub Action.

GitHub Action from https://tauri.app/v1/guides/building/cross-platform/#example-workflow is used.

The mac builds gets the following error (https://github.com/HuakunShen/devclean-ui/actions/runs/8976211618/job/24652561018)

run pkg_config fail: pkg-config has not been configured to support cross-compilation.

  Install a sysroot for the target platform and configure it via
  PKG_CONFIG_SYSROOT_DIR and PKG_CONFIG_PATH, or install a
  cross-compiling wrapper for pkg-config and set it via
  PKG_CONFIG environment variable.

  --- stderr
  thread 'main' panicked at /Users/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/openssl-sys-0.9.102/build/find_normal.rs:190:5:

  Could not find directory of OpenSSL installation, and this `-sys` crate cannot
  proceed without this knowledge. If OpenSSL is installed and this crate had
  trouble finding it,  you can set the `OPENSSL_DIR` environment variable for the
  compilation process.

  Make sure you also have the development packages of openssl installed.
  For example, `libssl-dev` on Ubuntu or `openssl-devel` on Fedora.

  If you're in a situation where you think the directory *should* be found
  automatically, please open a bug at https://github.com/sfackler/rust-openssl
  and include information about your system as well as this message.

  $HOST = aarch64-apple-darwin
  $TARGET = x86_64-apple-darwin
  openssl-sys = 0.9.102

  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...
       Error failed to build x86_64-apple-darwin binary: failed to build app
error Command failed with exit code 1.

This only happens on x86_64 and universal build.

I have tried brew install and setting OPENSSL_DIR environment variable to /opt/homebrew/opt/openssl@3.

This will fix the build, but the resulting app is not runnable after I enable code sign.

2. Mac Displays Problem Report


Termination Reason:    Namespace DYLD, Code 1 Library missing
Library not loaded: /opt/homebrew/*/libssl.3.dylib
Referenced from: <1DEB15F0-B614-32E2-9702-94EAC67721E3> /Users/USER/Downloads/devclean-ui.app/Contents/MacOS/devclean-ui
Reason: tried: '/opt/homebrew/*/libssl.3.dylib' (code signature in <36E19BFF-6DCD-35E2-B0B6-E78D41FEA3BC> '/opt/homebrew/Cellar/openssl@3/3.3.0/lib/libssl.3.dylib' not valid for use in process: mapping process and mapped file (non-platform) have different Team IDs), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/*/libssl.3.dylib' (no such file), '/opt/homebrew/*/libssl.3.dylib' (code signature in <36E19BFF-6DCD-35E2-B0B6-E78D41FEA3BC> '/opt/homebrew/Cellar/openssl@3/3.3.0/lib/libssl.3.dylib' not valid for use in process: mapping process and mapped file (non-platform) have different Team IDs), '/opt/homebrew/Cellar/openssl@3/3.3.0/lib/libssl.3.dylib' (code signature in <36E19BFF-6DCD-35E2-B0B6-E78D41FEA3BC> '/opt/homebrew/Cellar/openssl@3/3.3.0/lib/libssl.3.dylib' not
(terminated at launch; ignore backtrace)

image

image

Reproduction

Demo Repo: https://github.com/HuakunShen/devclean-ui

Here is a run without code sign, but x86_64 is missing ssl. https://github.com/HuakunShen/devclean-ui/actions/runs/8976211618/job/24652561018

This build is successful for arm https://github.com/HuakunShen/devclean-ui/actions/runs/8976344661/job/24653011389 But the resulting dmg file doesn't run, the arm dmg can be found here https://github.com/HuakunShen/devclean-ui/releases/tag/untagged-76fb0de92a9038b220da

Expected behavior

No response

Full tauri info output

✔] Environment
    - OS: Mac OS 14.5.0 X64
    ✔ Xcode Command Line Tools: installed
    ✔ 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-aarch64-apple-darwin (default)
    - node: 20.12.2
    - pnpm: 9.1.0
    - yarn: 1.22.22
    - npm: 10.5.0
    - bun: 1.1.7

[-] Packages
    - tauri [RUST]: 1.6.2
    - tauri-build [RUST]: 1.5.1
    - wry [RUST]: 0.24.8
    - tao [RUST]: 0.16.9
    - @tauri-apps/api [NPM]: 1.5.4
    - @tauri-apps/cli [NPM]: 1.5.12 (outdated, latest: 1.5.13)

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

Stack trace

No response

Additional context

No response

HuakunShen commented 1 week ago

Found partial solution

  1. Use macos-13 instead of macos-latest or macos-14
  2. Add environment variable OPENSSL_DIR=/usr/local/opt/openssl@3 for Mac builds

This will allow all builds to pass (i.e. aarch64, x86_64, universal). But:

Error is:

Termination Reason:    Namespace DYLD, Code 1 Library missing
Library not loaded: /usr/local/opt/openssl@3/lib/libssl.3.dylib
Referenced from: <01A9DF36-124E-3C84-BE38-97C738B1C800> /private/var/folders/*/devclean-ui.app/Contents/MacOS/devclean-ui
Reason: tried: '/usr/local/opt/openssl@3/lib/libssl.3.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/openssl@3/lib/libssl.3.dylib' (no such file), '/usr/local/opt/openssl@3/lib/libssl.3.dylib' (no such file)
(terminated at launch; ignore backtrace)
HuakunShen commented 1 week ago

This doesn't seem to be a bug of Tauri. After removing git2 from the app's dependency the problem is gone.

https://crates.io/crates/git2/0.18.3/dependencies

git2 depends on openssl-sys, this should be the source of problem.