mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-01-31 00:35:19 +01:00
fix: set webview2 path before initializing runtime (#14054)
* fix: set webview2 path before initializing runtime * wrong current_exe function
This commit is contained in:
5
.changes/fix-webview2-path-timing.md
Normal file
5
.changes/fix-webview2-path-timing.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
tauri: patch:bug
|
||||
---
|
||||
|
||||
Fixed an issue that caused the runtime WebView2 detection to fail for FixedRuntime installations.
|
||||
@@ -2165,6 +2165,26 @@ tauri::Builder::default()
|
||||
},
|
||||
};
|
||||
|
||||
// The env var must be set before the Runtime is created so that GetAvailableBrowserVersionString picks it up.
|
||||
#[cfg(windows)]
|
||||
{
|
||||
if let crate::utils::config::WebviewInstallMode::FixedRuntime { path } =
|
||||
&manager.config.bundle.windows.webview_install_mode
|
||||
{
|
||||
if let Some(exe_dir) = crate::utils::platform::current_exe()
|
||||
.ok()
|
||||
.and_then(|p| p.parent().map(|p| p.to_path_buf()))
|
||||
{
|
||||
std::env::set_var("WEBVIEW2_BROWSER_EXECUTABLE_FOLDER", exe_dir.join(path));
|
||||
} else {
|
||||
#[cfg(debug_assertions)]
|
||||
eprintln!(
|
||||
"failed to resolve resource directory; fallback to the installed Webview2 runtime."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(any(windows, target_os = "linux"))]
|
||||
let mut runtime = if self.runtime_any_thread {
|
||||
R::new_any_thread(runtime_args)?
|
||||
@@ -2242,25 +2262,6 @@ tauri::Builder::default()
|
||||
app.manage(ChannelDataIpcQueue::default());
|
||||
app.handle.plugin(crate::ipc::channel::plugin())?;
|
||||
|
||||
#[cfg(windows)]
|
||||
{
|
||||
if let crate::utils::config::WebviewInstallMode::FixedRuntime { path } =
|
||||
&app.manager.config().bundle.windows.webview_install_mode
|
||||
{
|
||||
if let Ok(resource_dir) = app.path().resource_dir() {
|
||||
std::env::set_var(
|
||||
"WEBVIEW2_BROWSER_EXECUTABLE_FOLDER",
|
||||
resource_dir.join(path),
|
||||
);
|
||||
} else {
|
||||
#[cfg(debug_assertions)]
|
||||
eprintln!(
|
||||
"failed to resolve resource directory; fallback to the installed Webview2 runtime."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let handle = app.handle();
|
||||
|
||||
// initialize default tray icon if defined
|
||||
|
||||
Reference in New Issue
Block a user