tauri-apps / tauri

Build smaller, faster, and more secure desktop applications with a web frontend.
https://tauri.app
Apache License 2.0
81.92k stars 2.46k forks source link

[bug] OS Error 13: Permission Denied #7460

Open KICKGodz opened 1 year ago

KICKGodz commented 1 year ago

Describe the bug

I am trying to use the sidecar for building in binaries to the app but get this error everytime

thread 'tokio-runtime-worker' panicked at 'Failed to spawn command: Io(Os { code: 13, kind: PermissionDenied, message: "Permission denied" })', src/main.rs:68:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

I saw a previous post about this same problem but it fixed when the person upgraded their dependencies but mine are already up to date as of "1.4".

If any more details are needed let me know please. I tried looking at other examples and nothing has worked. Also tauri permissions are fully allowed so that shouldn't be the issue.

Reproduction

tauri.conf.json

{
    "build": {
        "beforeDevCommand": "yarn dev",
        "beforeBuildCommand": "yarn build",
        "devPath": "http://localhost:1420",
        "distDir": "../dist",
        "withGlobalTauri": true
    },
    "package": {
        "productName": "Neko Launcher",
        "version": "0.0.0"
    },
    "tauri": {
        "allowlist": {
            "all": false,
            "shell": {
                "sidecar": true,
                "scope": [
                    { "name": "bin/auth", "sidecar": true }
                ]
            },
            "window": {
                "close": true,
                "startDragging": true
            },
            "http": {
                "scope": ["https://api.minecraftservices.com/*"],
                "all": true,
                "request": true
            },
            "fs": {
                "all": true
            },
            "path": {
                "all": true
            },
            "os": {
                "all":true
            },
            "notification": {
                "all": true
            }
        },
        "bundle": {
            "active": true,
            "targets": "all",
            "identifier": "me.media.dev",
            "icon": [
                "icons/32x32.png",
                "icons/128x128.png",
                "icons/128x128@2x.png",
                "icons/icon.icns",
                "icons/icon.ico"
            ], 
            "externalBin": ["bin/auth"],
            "deb": {
                "depends": []
            }
        },
        "security": {
            "csp": "default-src 'self'"
        },
        "windows": [
            {
                "fullscreen": false,
                "resizable": true,
                "decorations": false,
                "transparent": true,
                "title": "Neko Launcher",
                "width": 1100,
                "height": 700
            }
        ],
        "macOSPrivateApi": true
    }
}

Here the sidecar is being called in a tauri command:

#[tauri::command]
async fn run_client(email: String, password: String) -> Option<String> {
    let (mut rx, _child) = Command::new_sidecar("auth")
        .expect("Failed to create sidecar process")
        // .args([email.as_str(), password.as_str()])
        .spawn()
        .expect("Failed to spawn command");

    let mut json_output = String::new();
    while let Some(event) = rx.recv().await {
        if let CommandEvent::Stdout(line) = event.clone() {
            json_output.push_str(&line);
        }
        // If the event is the end of the child process, print the output.
        if let CommandEvent::Terminated(payload) = event {
            println!("Child exited with code {:?}", payload.code);
            break;
        }
    }
    let token: MinecraftToken = match serde_json::from_str(&json_output) {
        Ok(token) => token,
        Err(err) => {
            eprintln!("Error parsing JSON: {}", err);
            return None;
        }
    };

    Some(token.token)
}

I used to have it working when I manually inputted the directory of the executable but now no longer works.

ls src-tauri

Cargo.lock      bin             cache           src             tauri.conf.json
Cargo.toml      build.rs        icons           target

ls src-tauri/bin

auth-x86_64-apple-darwin        auth-x86_64-pc-windows-msvc.exe auth-x86_64-unknown-linux-gnu

Expected behavior

To run the auth binary

Platform and versions

[✔] Environment
    - OS: Mac OS 12.4.0 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.70.0 (90c541806 2023-05-31)
    ✔ Cargo: 1.70.0 (ec8a8a0ca 2023-04-25)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-x86_64-apple-darwin (default)
    - node: 18.4.0
    - pnpm: 8.6.9
    - yarn: 3.6.1
    - npm: 8.12.1

[-] Packages
    - tauri [RUST]: 1.4.1
    - tauri-build [RUST]: 1.4.0
    - wry [RUST]: 0.24.3
    - tao [RUST]: 0.16.2
    - @tauri-apps/api [NPM]: 1.4.0
    - @tauri-apps/cli [NPM]: 1.4.0

[-] App
    - build-type: bundle
    - CSP: default-src 'self'
    - distDir: ../dist
    - devPath: http://localhost:1420/
    - bundler: Vite

Stack trace

thread 'tokio-runtime-worker' panicked at 'Failed to spawn command: Io(Os { code: 13, kind: PermissionDenied, message: "Permission denied" })', src/main.rs:68:10
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
   1: core::panicking::panic_fmt
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
   2: core::result::unwrap_failed
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/result.rs:1687:5
   3: core::result::Result<T,E>::expect
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/result.rs:1046:23
   4: neko::run_client::{{closure}}
             at ./src/main.rs:64:28
   5: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/future/future/map.rs:55:37
   6: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/futures-util-0.3.28/src/lib.rs:91:13
   7: neko::main::{{closure}}::{{closure}}
             at ./src/main.rs:62:1
   8: tauri::hooks::InvokeResolver<R>::respond_async_serialized::{{closure}}
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tauri-1.4.1/src/hooks.rs:195:32
   9: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/task/core.rs:311:17
  10: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/loom/std/unsafe_cell.rs:14:9
  11: tokio::runtime::task::core::Core<T,S>::poll
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/task/core.rs:300:13
  12: tokio::runtime::task::harness::poll_future::{{closure}}
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/task/harness.rs:476:19
  13: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panic/unwind_safe.rs:271:9
  14: std::panicking::try::do_call
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:485:40
  15: ___rust_try
  16: std::panicking::try
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:449:19
  17: std::panic::catch_unwind
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panic.rs:140:14
  18: tokio::runtime::task::harness::poll_future
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/task/harness.rs:464:18
  19: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/task/harness.rs:198:27
  20: tokio::runtime::task::harness::Harness<T,S>::poll
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/task/harness.rs:152:15
  21: tokio::runtime::task::raw::poll
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/task/raw.rs:276:5
  22: tokio::runtime::task::raw::RawTask::poll
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/task/raw.rs:200:18
  23: tokio::runtime::task::LocalNotified<S>::run
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/task/mod.rs:400:9
  24: tokio::runtime::scheduler::multi_thread::worker::Context::run_task::{{closure}}
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/scheduler/multi_thread/worker.rs:576:13
  25: tokio::runtime::coop::with_budget
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/coop.rs:107:5
  26: tokio::runtime::coop::budget
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/coop.rs:73:5
  27: tokio::runtime::scheduler::multi_thread::worker::Context::run_task
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/scheduler/multi_thread/worker.rs:575:9
  28: tokio::runtime::scheduler::multi_thread::worker::Context::run
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/scheduler/multi_thread/worker.rs:526:24
  29: tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}::{{closure}}
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/scheduler/multi_thread/worker.rs:491:21
  30: tokio::runtime::context::scoped::Scoped<T>::set
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/context/scoped.rs:40:9
  31: tokio::runtime::context::set_scheduler::{{closure}}
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/context.rs:176:26
  32: std::thread::local::LocalKey<T>::try_with
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/thread/local.rs:252:16
  33: std::thread::local::LocalKey<T>::with
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/thread/local.rs:228:9
  34: tokio::runtime::context::set_scheduler
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/context.rs:176:9
  35: tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/scheduler/multi_thread/worker.rs:486:9
  36: tokio::runtime::context::runtime::enter_runtime
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/context/runtime.rs:65:16
  37: tokio::runtime::scheduler::multi_thread::worker::run
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/scheduler/multi_thread/worker.rs:478:5
  38: tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{{closure}}
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/scheduler/multi_thread/worker.rs:447:45
  39: <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/blocking/task.rs:42:21
  40: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/task/core.rs:311:17
  41: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/loom/std/unsafe_cell.rs:14:9
  42: tokio::runtime::task::core::Core<T,S>::poll
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/task/core.rs:300:13
  43: tokio::runtime::task::harness::poll_future::{{closure}}
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/task/harness.rs:476:19
  44: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panic/unwind_safe.rs:271:9
  45: std::panicking::try::do_call
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:485:40
  46: ___rust_try
  47: std::panicking::try
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:449:19
  48: std::panic::catch_unwind
             at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panic.rs:140:14
  49: tokio::runtime::task::harness::poll_future
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/task/harness.rs:464:18
  50: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/task/harness.rs:198:27
  51: tokio::runtime::task::harness::Harness<T,S>::poll
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/task/harness.rs:152:15
  52: tokio::runtime::task::raw::poll
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/task/raw.rs:276:5
  53: tokio::runtime::task::raw::RawTask::poll
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/task/raw.rs:200:18
  54: tokio::runtime::task::UnownedTask<S>::run
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/task/mod.rs:437:9
  55: tokio::runtime::blocking::pool::Task::run
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/blocking/pool.rs:159:9
  56: tokio::runtime::blocking::pool::Inner::run
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/blocking/pool.rs:513:17
  57: tokio::runtime::blocking::pool::Spawner::spawn_thread::{{closure}}
             at /Users/{name}/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.29.1/src/runtime/blocking/pool.rs:471:13
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Additional context

The auth binary is just a compiled node project that uses prismarine-auth

pjvds commented 10 months ago

@KICKGodz just wondering if this is still an issue for you?

KICKGodz commented 9 months ago

Hi @pjvds, I ended up getting around the problem I believe by using electron (don't really remember). It's been a while since I worked on the project so I don't know if it's still happening.

gschier commented 1 month ago

This happens for me on Windows. Deleting the target directory solves it but it can't be deleted because the sidecar is still running. You have to kill the sidecar manually and then the delete works and the app can build again.

gschier commented 1 month ago

Okay, I have fixed the issue where the binary is not killed on app exit on Windows and this still persists.