Hello, I am starting my journey with Tauri (and Rust!) and I'm having trouble with getting a sidecar working.
Here's my lib.rs file:
use tauri_plugin_shell::ShellExt;
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
//let _ = CryptoProvider::install_default();
tauri::Builder::default()
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_websocket::init())
.plugin(tauri_plugin_shell::init())
.invoke_handler(tauri::generate_handler![greet])
.setup(setup)
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
fn setup<'a>(app: &'a mut tauri::App) -> Result<(), Box<dyn std::error::Error>> {
let sidecar_command = app.shell().sidecar("Glass.Server").unwrap();
let (mut rx, mut _child) = sidecar_command
.spawn()
.expect("Failed to spawn sidecar");
Ok(())
}
If I comment the lines inside the setup function (aside from Ok(())), the app works fine. Otherwise, I get a new window created every second or so until I stop the npm run tauri dev command in my terminal.
I added the following permissions in my default.json :
"permissions": [
"core:default",
"opener:default",
"websocket:default",
{
"identifier": "shell:allow-spawn",
"allow": [
{
"name": "../src-server/Glass.Server/bin/Release/net8.0/win-x64/publish/Glass.Server",
"sidecar": true
}
]
},
"shell:allow-open"
]
I am running on Windows and I do have an executable located here: src-server\Glass.Server\bin\Release\net8.0\win-x64\publish\Glass.Server-x86_64-pc-windows-msvc.exe
Any help would be really appreciated, thanks 🙂