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] The system cannot find the file specified when launching the sidecar #2139

Open
ribull opened this issue Dec 4, 2024 · 1 comment
Open
Labels
plugin: shell question Further information is requested

Comments

@ribull
Copy link

ribull commented Dec 4, 2024

Describe the bug

I have a sidecar located in binaries/ that is not loaded correctly when called from javascript. It fails every time (as in the proc = await cmd.spawn(); line throws an error) and the resulting error (which is only a string) is the very helpful message: "The system cannot find the file specified. (os error 2)". I have been able to debug the frontend (which hasn't been very helpful, I can just see that it's failing when calling the rust), but have not been able to successfully debug the backend.

Several iterations ago I had this running with an absolute path calling the program using cmd.spawn() and it seemed to work but that was many iterations ago and I didn't record the results or code for posterity. I want to use the sidecar so that I can fully contain the launched process within the application and I don't need to manage child processes or anything.

My tauri.conf.json:

{
    ...,
    "externalBin": [
      "binaries/RLL.Utility.DataOrchestrator"
    ]
}

My capabilities/default.json:

{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "default",
  "description": "Capability for the main window",
  "windows": [
    "main"
  ],
  "permissions": [
    "core:default",
    "shell:allow-open",
    "dialog:default",
    {
      "identifier": "shell:allow-spawn",
      "allow": [
        {
          "sidecar": true,
          "name": "binaries/RLL.Utility.DataOrchestrator"
        }
      ]
    },
    {
      "identifier": "shell:allow-kill",
      "allow": [
        {
          "sidecar": true,
          "name": "binaries/RLL.Utility.DataOrchestrator"
        }
      ]
    },
    "shell:default"
  ]
}

My svelte code for spawning the sidecar:

  import { Child, Command } from "@tauri-apps/plugin-shell";

  interface Props {
    consoleHistory?: string;
  }

  let { consoleHistory = $bindable("") }: Props = $props();
  let proc: Child | undefined = $state();

  async function startListener() {
    try {
      const cmd = Command.sidecar("binaries/RLL.Utility.DataOrchestrator");

      proc = await cmd.spawn();
      console.log(proc);
    } catch (err) {
      console.log(JSON.stringify(err));
      proc = undefined;
    }
  }

  async function stopListener() {
    await proc?.kill();
    proc = undefined;
  }

  async function clearConsole() {
    consoleHistory = "";
  }

I also have the executable with the appropriate triplet appended in the src-tauri/binaries folder. The name of the executable is RLL.Utility.DataOrchestrator-x86_64-pc-windows-msvc.exe and the program builds and I see the resulting exe in the target/debug directory.

Reproduction

  1. Use the configuration I specified above.
  2. Click the button on the frontend that executes the appropriate javascript.
  3. Inspect the frontend devtools for the logged error.

Expected behavior

The command.spawn() line to not throw an error and peacefully start the specified process.

Full tauri info output

[✔] Environment
    - OS: Windows 10.0.19045 x86_64 (X64)
    ✔ WebView2: 131.0.2903.70
    ✔ MSVC:
        - Visual Studio Build Tools 2019
        - Visual Studio Community 2022
    ✔ rustc: 1.82.0 (f6e511eec 2024-10-15)
    ✔ cargo: 1.82.0 (8f40fc59f 2024-08-21)
    ✔ rustup: 1.27.1 (54dd3d00f 2024-04-24)
    ✔ Rust toolchain: stable-x86_64-pc-windows-msvc (default)
    - node: 20.10.0
    - pnpm: 9.14.2
    - npm: 10.2.3

[-] Packages
    - tauri 🦀: 2.1.1
    - tauri-build 🦀: 2.0.3   
    - wry 🦀: 0.47.2
    - tao 🦀: 0.30.8
    - @tauri-apps/api : 2.1.1
    - @tauri-apps/cli : 2.1.0

[-] Plugins
    - tauri-plugin-shell 🦀: 2.0.2
    - @tauri-apps/plugin-shell : 2.0.1      
    - tauri-plugin-dialog 🦀: 2.0.3
    - @tauri-apps/plugin-dialog : 2.0.1     
    - tauri-plugin-fs 🦀: 2.0.3
    - @tauri-apps/plugin-fs : not installed!

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

Stack trace

No response

Additional context

No response

@FabianLars FabianLars transferred this issue from tauri-apps/tauri Dec 4, 2024
@FabianLars FabianLars added question Further information is requested plugin: shell labels Dec 4, 2024
@Aderemi-Adesada
Copy link

i am having the same issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin: shell question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants