Panic when calling shell() on AppHandle #11963
-
I've been trying to start a sidecar with Tauri v2, but I keep getting a
[package]
name = "shell-test"
version = "0.1.0"
description = "A Tauri App"
authors = ["you"]
edition = "2021"
[lib]
name = "shell_test_lib"
crate-type = ["staticlib", "cdylib", "rlib"]
[build-dependencies]
tauri-build = { version = "2", features = [] }
[dependencies]
tauri = { version = "2", features = [] }
tauri-plugin-opener = "2"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
tauri-plugin-shell = "2.2.0"
use tauri::App;
use tauri_plugin_shell::ShellExt;
#[tauri::command]
fn start_sidecar(app_handle: tauri::AppHandle) -> () {
let shell = app_handle.shell();
let command = shell
.sidecar("node-web-server")
.unwrap();
()
}
fn set_up_tauri_app(app: &mut App) -> () {
start_sidecar(app.handle().clone());
()
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.setup(|app| {
set_up_tauri_app(app);
Ok(())
})
.invoke_handler(tauri::generate_handler![start_sidecar])
.run(tauri::generate_context!())
.expect("error while running tauri application");
} The error and backtrace:
|
Beta Was this translation helpful? Give feedback.
Answered by
FabianLars
Dec 13, 2024
Replies: 1 comment
-
You have to register the shell plugin like the opener plugin on the tauri::Builder before you can use the shell() function |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
FabianLars
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You have to register the shell plugin like the opener plugin on the tauri::Builder before you can use the shell() function