tauri-apps / tauri

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

[bug] webview2-runtime on circleci build #7024

Open nocke opened 1 year ago

nocke commented 1 year ago

I have a fresh tauri 1.3.0 project, using Node 20, rust 1.69.0 and Svelte 3.59 and I am trying to achieve a tripple build using circle.ci:

Linux and MacOS work nice, but Windows has a problem with the webview2 dependency:

What do I need to fix?

All starting nicely:

> tauri-browser@0.0.5 tauri:build
> tauri build

     Running beforeBuildCommand `npm run build`

> tauri-browser@0.0.5 build
> vite build

vite v4.3.8 building for production...
transforming...
✓ 39 modules transformed.
rendering chunks...
computing gzip size...
dist/index.html                  0.48 kB │ gzip:  0.32 kB
dist/assets/index-dd351b52.css   3.02 kB │ gzip:  0.96 kB
dist/assets/index-1538e646.js   41.60 kB │ gzip: 11.71 kB
✓ built in 1.56s
    Updating crates.io index
 Downloading crates ...
  Downloaded adler v1.0.2
  ...

...more Downloading and Compilation without any warnings or errors, but then...

   Compiling raw-window-handle v0.5.0
   Compiling toml v0.7.3
error: failed to run custom build command for `webview2-com-sys v0.19.0`

Caused by:
  process didn't exit successfully: `C:\Users\circleci.PACKER-64370BA5\project\src-tauri\target\release\build\webview2-com-sys-bbbb0c2631a4b59f\build-script-build` (exit code: 1)
  --- stdout
  cargo:rustc-link-search=native=C:\Users\circleci.PACKER-64370BA5\project\src-tauri\target\release\build\webview2-com-sys-c28652fe6978543c\out\x64

  --- stderr
  Copy from "C:\\Users\\circleci.PACKER-64370BA5\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\webview2-com-sys-0.19.0\\arm64\\WebView2Loader.dll" -> "C:\\Users\\circleci.PACKER-64370BA5\\project\\src-tauri\\target\\release\\build\\webview2-com-sys-c28652fe6978543c\\out\\arm64\\WebView2Loader.dll"
  Copy from "C:\\Users\\circleci.PACKER-64370BA5\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\webview2-com-sys-0.19.0\\arm64\\WebView2Loader.dll.lib" -> "C:\\Users\\circleci.PACKER-64370BA5\\project\\src-tauri\\target\\release\\build\\webview2-com-sys-c28652fe6978543c\\out\\arm64\\WebView2Loader.dll.lib"
  Copy from "C:\\Users\\circleci.PACKER-64370BA5\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\webview2-com-sys-0.19.0\\arm64\\WebView2LoaderStatic.lib" -> "C:\\Users\\circleci.PACKER-64370BA5\\project\\src-tauri\\target\\release\\build\\webview2-com-sys-c28652fe6978543c\\out\\arm64\\WebView2LoaderStatic.lib"
  Copy from "C:\\Users\\circleci.PACKER-64370BA5\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\webview2-com-sys-0.19.0\\x64\\WebView2Loader.dll" -> "C:\\Users\\circleci.PACKER-64370BA5\\project\\src-tauri\\target\\release\\build\\webview2-com-sys-c28652fe6978543c\\out\\x64\\WebView2Loader.dll"
  Copy from "C:\\Users\\circleci.PACKER-64370BA5\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\webview2-com-sys-0.19.0\\x64\\WebView2Loader.dll.lib" -> "C:\\Users\\circleci.PACKER-64370BA5\\project\\src-tauri\\target\\release\\build\\webview2-com-sys-c28652fe6978543c\\out\\x64\\WebView2Loader.dll.lib"
  Copy from "C:\\Users\\circleci.PACKER-64370BA5\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\webview2-com-sys-0.19.0\\x64\\WebView2LoaderStatic.lib" -> "C:\\Users\\circleci.PACKER-64370BA5\\project\\src-tauri\\target\\release\\build\\webview2-com-sys-c28652fe6978543c\\out\\x64\\WebView2LoaderStatic.lib"
  Copy from "C:\\Users\\circleci.PACKER-64370BA5\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\webview2-com-sys-0.19.0\\x86\\WebView2Loader.dll" -> "C:\\Users\\circleci.PACKER-64370BA5\\project\\src-tauri\\target\\release\\build\\webview2-com-sys-c28652fe6978543c\\out\\x86\\WebView2Loader.dll"
  Copy from "C:\\Users\\circleci.PACKER-64370BA5\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\webview2-com-sys-0.19.0\\x86\\WebView2Loader.dll.lib" -> "C:\\Users\\circleci.PACKER-64370BA5\\project\\src-tauri\\target\\release\\build\\webview2-com-sys-c28652fe6978543c\\out\\x86\\WebView2Loader.dll.lib"
  Copy from "C:\\Users\\circleci.PACKER-64370BA5\\.cargo\\registry\\src\\github.com-1ecc6299db9ec823\\webview2-com-sys-0.19.0\\x86\\WebView2LoaderStatic.lib" -> "C:\\Users\\circleci.PACKER-64370BA5\\project\\src-tauri\\target\\release\\build\\webview2-com-sys-c28652fe6978543c\\out\\x86\\WebView2LoaderStatic.lib"

  Error: Io(Error { kind: NotFound, message: "program not found" })
warning: build failed, waiting for other jobs to finish...
       Error failed to build app: failed to build app

Exited with code exit status 1
CircleCI received exit code 1

This is my .circleci/config.yml:

( and yes, I got a checksum error, until I ignored it. And I also tried the comment out approach for installing webview)

version: 2.1

orbs:
  node: circleci/node@5.1.0
  win: circleci/windows@5.0
  mac: circleci/macos@1.1.0

jobs:
  build-linux:
    docker:
      - image: cimg/rust:1.69.0-node
    steps:
      - checkout
      - run:
          name: Install Dependencies
          command: |
            sudo apt-get update
            sudo apt-get install -y curl wget
            sudo apt-get install -y libglib2.0-dev libwebkit2gtk-4.0-dev build-essential
            sudo apt-get install -y libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev
      - node/install:
          node-version: "20"
      - run: npm install
      - run: npm run tauri:build
      - run:
          name: Prepare artifacts
          command: |
            mkdir -p ./build/linux
            mv ./src-tauri/target/release/bundle/deb/*.deb ./build/linux
            mv ./src-tauri/target/release/bundle/appimage/*.AppImage ./build/linux
      - store_artifacts:
          path: build

  build-windows:
    executor: win/default
    steps:
      - checkout
      - run:
          name: Install Node.js
          command: choco install nodejs -y --no-progress --version=20.0.0
      - run:
          name: Install Rust
          command: choco install rust -y --no-progress
      - run:
          name: Show Rust Version
          command: rustc --version
      - run:
          name: Show Cargo Version
          command: cargo --version
      - run:
          name: Install Dependencies
          command: choco install gtk-runtime -y --no-progress
      - run:
          name: Install Microsoft WebView2 Runtime
          command: |
            choco install webview2-runtime -y --no-progress --ignore-checksums
      # - run:
      #     name: Install WebView2 Runtime
      #     shell: powershell.exe
      #     command: |
      #       $webview2RTUrl = "https://go.microsoft.com/fwlink/p/?LinkId=2124703"
      #       $webview2RTFile = "MicrosoftEdgeWebview2Setup.exe"
      #       Invoke-WebRequest -Uri $webview2RTUrl -OutFile $webview2RTFile
      #       Start-Process -FilePath $webview2RTFile -Args "/silent /install" -NoNewWindow -Wait
      - run: npm install
      - run: npm run tauri:build
      - run:
          name: Prepare artifacts
          command: |
            New-Item -ItemType Directory -Path "$HOME\\project\\build\\windows"
            Move-Item -Path "C:\\path\\to\\your\\windows\\artifacts\\*" -Destination "$HOME\\project\\build\\windows"
      - store_artifacts:
          path: "$HOME\\project\\build"

  build-macos:
    macos:
      xcode: 14.3.0
    steps:
      - checkout
      - run:
          name: Install Node.js
          command: brew install node@20 && echo 'export PATH="/usr/local/opt/node@20/bin:$PATH"' >> ~/.bash_profile
      - run:
          name: Install Rust
          command: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
      - run:
          name: Source bash profile
          command: source ~/.bash_profile
      - run: npm install
      - run: npm run tauri:build
      - run:
          name: Move Binary to Desired Location
          command: |
            mkdir -p ./build/macos
            mv ./src-tauri/target/release/bundle/macos/*.app ./build/macos
            mv ./src-tauri/target/release/bundle/dmg/*.dmg ./build/macos
      - store_artifacts:
          path: ./build

workflows:
  version: 2
  build:
    jobs:
      - build-linux
      - build-windows
      - build-macos
szgerg commented 1 year ago

I have the same issue on WIN11, any progress with this?

FabianLars commented 1 year ago

@szgerg Can you post the full error you're getting? And if you're talking about an actual win11 "client" and not a server/ci the output of the tauri info command too please.

FabianLars commented 1 year ago

Also, the only similar issue i found was this: https://github.com/wravery/webview2-rs/issues/7#issuecomment-1071100283, and it even mentioned choco so can you make sure rustfmt is installed too (i don't know anything about choco so no idea how that will look like)

WalrusSoup commented 1 year ago

The windows orb in circleci does not seem to persist paths between run commands. I tried literally everything and cannot seem to get cargo into the path. Anyway, we inlined it.

Choco appears to be missing rustfmt required for the webview library downstream. If you install rustup without yeeting it, then it will just go back to using cargo with choco and die compiling.

After a lot of trial and error, we got this setup working on circleci:

jobs:
  build-windows:
    executor: 
      name: win/default
      shell: bash.exe
    steps:
      - checkout
      - run: choco uninstall rust
      - run: curl https://win.rustup.rs/x86_64 -o rustup-init.exe
      - run: ./rustup-init.exe -y --default-toolchain 1.68.2-x86_64-pc-windows-msvc # CONFIGURE ME 
      - run: nvm install 18.16.0 && nvm use 18.16.0
      - restore_cache:
          key: v1-dependencies-windows-{{ checksum "package-lock.json" }}
      - run: 
          name: "[Windows] Run NPM"
          command: npm install
      - save_cache: 
          key: v1-dependencies-windows-{{ checksum "package-lock.json" }}
          paths:
            - "node_modules"
      - restore_cache:
          key: v1-dependencies-windows-{{ checksum "src-tauri/Cargo.lock" }}
      - run: 
          shell: powershell
          name: "[Windows] Build Windows Version"
          command: |
            $env:Path += ";C:\Users\circleci\.cargo\bin\"
            $env:CARGO_NET_GIT_FETCH_WITH_CLI = "true"
            npm run tauri:build:windows
      - save_cache: 
          key: v1-dependencies-windows-{{ checksum "src-tauri/Cargo.lock" }}
          paths:
            - "~/.cargo"