#Single instance plugin not working by default (function takes 1 argument but 0 arguments supplied)

11 messages · Page 1 of 1 (latest)

keen pine
#

Just installed the single instance plugin and its expecting an argument. I know practically nothing about rust so don't know what to provide it.

The plugin page says it should just work out the box so not sure what it wants.

Error message:

error[E0061]: this function takes 1 argument but 0 arguments were supplied
  --> src\lib.rs:10:17
   |
10 |         .plugin(tauri_plugin_single_instance::init())
   |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-- argument #1 is missing
   |
note: function defined here
  --> C:\Users\Ollie\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\tauri-plugin-single-instance-2.3.2\src\lib.rs:31:8
   |
31 | pub fn init<R: Runtime, F: FnMut(&AppHandle<R>, Vec<String>, String) + Send + Sync + 'static>(
   |        ^^^^
help: provide the argument
   |
10 |         .plugin(tauri_plugin_single_instance::init(/* f */))
   |                                                    +++++++

lib.rs

// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
#[tauri::command]
fn greet(name: &str) -> String {
    format!("Hello, {}! You've been greeted from Rust!", name)
}

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        .plugin(tauri_plugin_single_instance::init())
        .plugin(tauri_plugin_deep_link::init())
        .plugin(tauri_plugin_fs::init())
        .plugin(tauri_plugin_opener::init())
        .invoke_handler(tauri::generate_handler![greet])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

Tauri info:

[✔] Environment
    - OS: Windows 10.0.19045 x86_64 (X64)
    ✔ WebView2: 138.0.3351.121
    ✔ MSVC: Visual Studio Community 2019
    ✔ rustc: 1.88.0 (6b00bc388 2025-06-23)
    ✔ cargo: 1.88.0 (873a06493 2025-05-10)
    ✔ rustup: 1.28.2 (e4f3ad6f8 2025-04-28)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 22.7.0
    - npm: 8.1.2

[-] Packages
    - tauri :crab:: 2.7.0
    - tauri-build :crab:: 2.3.1
    - wry :crab:: 0.52.1
    - tao :crab:: 0.34.0
    - @tauri-apps/api : 2.7.0
    - @tauri-apps/cli : 2.7.1

[-] Plugins
    - tauri-plugin-deep-link :crab:: 2.4.1
    - @tauri-apps/plugin-deep-link : 2.4.1
    - tauri-plugin-fs :crab:: 2.4.1
    - @tauri-apps/plugin-fs : 2.4.1
    - tauri-plugin-opener :crab:: 2.4.0
    - @tauri-apps/plugin-opener : 2.4.0
    - tauri-plugin-single-instance :crab:: 2.3.2
    - @tauri-apps/plugin-single-instance : 0.1.0

[-] App
    - build-type: bundle
    - CSP: unset
    - frontendDist: ../dist
    - devUrl: http://localhost:1420/
    - framework: React
    - bundler: Vite
#

Copying the function signature from the plugin page just empty lets it compile, but this is clearly unintended behaviour as the docs dont state this is mandatory:

.plugin(tauri_plugin_single_instance::init(|_app, _args, _cwd| {
          // NOOP
        }))
long sparrow
#

The manual section has the same line than you added

flat star
keen pine
#

all i did was run npm run tauri add single-instance as instructed

keen pine
#

assumed was a bug but just checking it wasnt a me issue

#

also im not sure its accurate to say the user "mindlessly ran" the command, when the docs quite literally say

The plugin is already installed and initialized, and it should be functioning correctly right away.

flat star
#

also im not sure its accurate to say the user "mindlessly ran" the command, when the docs quite literally say
Maybe not in your case but it's quite common that people don't even check the docs before 🤷

#

i think the docs are from before tauri add was really a thing not sure