Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] Error/crash when trying to run npm run tauri:serve using webviewFixedRuntimePath in tauri.conf.json #4308

Closed
ksumarine opened this issue Jun 9, 2022 · 2 comments

Comments

@ksumarine
Copy link

Describe the bug

Attempting to use a fixed WebView2 runtime fails in dev mode in Windows. Creating a production .msi installer does work and packages the runtime correctly, however. The issue seems to only be when trying to run in development, e.g., npm run tauri:serve

Reproduction

  1. Create a new tauri app
  2. Download a fixed version runtime from https://developer.microsoft.com/en-us/microsoft-edge/webview2/
  3. Extract the .cab file to ./src-tauri/webview2/, which creates a Microsoft.WebView2.FFixedVersionRuntime.102.x.xxx... folder
  4. In tauri.conf.json add webviewFixedRuntimePath to tauri > bundle > windows with webview2/Microsoft.WebView2.FFixedVersionRuntime.102.x.xxx.../ for the path value
  5. Try and run npm run tauri:serve
  6. App crashes on startup with error...
    Finished dev [unoptimized + debuginfo] target(s) in 9.19s
     Running `target\debug\APP_NAME.exe`
 }))))', src\main.rs:332:10error while running tauri application: Runtime(CreateWebview(WebView2Error(WindowsError(Error { code: 0x80070002, message: The system cannot find the file specified.
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\std\src\panicking.rs:584
   1: core::panicking::panic_fmt
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\core\src\panicking.rs:143
   2: core::result::unwrap_failed
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\/library\core\src\result.rs:1785
   3: enum$<core::result::Result<tuple$<>,enum$<tauri::error::Error> >, 0, 27, Err>::expect<tuple$<>,enum$<tauri::error::Error> >
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\core\src\result.rs:1035
   4: APP_NAME::main
             at .\src\main.rs:304
   5: core::ops::function::FnOnce::call_once<void (*)(),tuple$<> >
             at /rustc/fe5b13d681f25ee6474be29d748c65adcd91f69e\library\core\src\ops\function.rs:227
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: process didn't exit successfully: `target\debug\APP_NAME.exe` (exit code: 101)

Expected behavior

App should start as expected but using the fixed webview2 runtime

Platform and versions

Not sure why the output of `tauri info` shows that Webview2 is not installed, but it is!

Environment
  › OS: Windows 10.0.18363 X64
  › Webview2: Not installed!
  › MSVC: 
      - Visual Studio Build Tools 2019
  › Node.js: 16.13.0
  › npm: 8.1.0
  › pnpm: Not installed!
  › yarn: Not installed!
  › rustup: 1.24.3
  › rustc: 1.61.0
  › cargo: 1.61.0
  › Rust toolchain: stable-x86_64-pc-windows-msvc

Packages
  › @tauri-apps/cli [NPM]: 1.0.0-rc.13
  › @tauri-apps/api [NPM]: 1.0.0-rc.6
  › tauri [RUST]: 1.0.0-rc.14,
  › tauri-build [RUST]: 1.0.0-rc.12,
  › tao [RUST]: 0.9.1,
  › wry [RUST]: 0.17.0,

App
  › build-type: bundle
  › CSP: default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  › distDir: ../dist
  › devPath: http://localhost:8080/
  › framework: Vue.js (Vue CLI)
  › bundler: Webpack

App directory structure
  ├─ .git
  ├─ dist
  ├─ node_modules
  ├─ public
  ├─ resources
  ├─ src
  └─ src-tauri

Stack trace

No response

Additional context

Example repo: https://github.com/ksumarine/tauri-dev-webview2runtime-issue

  • FYI, runtime files are not included, the .cab must be downloaded and extracted into the project
@FabianLars
Copy link
Member

FabianLars commented Jun 9, 2022

@whoever wants to try to fix this: the issue is that the core (app.rs) always sets the runtime env var if there is a path set in the config. But since it uses the resources dir (where the WebView is not stored or copied into like actual "resources") it always specifies an invalid path in development.

@lucasfernog
Copy link
Member

Nice catch, I meant to double check if this was still working recently. Seems like the move to copying resources to tauri-build broke it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants