tauri-apps / tauri

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

[bug] shell command fails after build #8400

Closed martin-opensky closed 10 months ago

martin-opensky commented 10 months ago

Describe the bug

When executing a simple command during dev (node -v) the command is successful but after deploying (yarn tauri build) and installing on MacOs, running the command fails and a 400 response is returned with the error "No such file or directory (os error 2)"

Xnapper-2023-12-14-16 37 41

Reproduction

You can checkout this simple starter project: https://github.com/martin-opensky/create-tauri-2-next-14-app/tree/tauri-alpha-bug-1

Code is in: https://github.com/martin-opensky/create-tauri-2-next-14-app/blob/tauri-alpha-bug-1/src/components/ActionBar.tsx

Lines 81 - 88

Expected behavior

If the command works in dev it should work once the app is built

Platform and versions

[✔] Environment
    - OS: Mac OS 14.1.2 X64
    ✔ Xcode Command Line Tools: installed
    ✔ rustc: 1.74.1 (a28077b28 2023-12-04)
    ✔ cargo: 1.74.1 (ecb9851af 2023-10-18)
    ✔ rustup: 1.26.0 (5af9b9484 2023-04-05)
    ✔ Rust toolchain: stable-aarch64-apple-darwin (default)
    - node: 20.5.1
    - pnpm: 8.6.3
    - yarn: 1.22.19
    - npm: 9.8.0

[-] Packages
    - tauri [RUST]: 2.0.0-alpha.18
    - tauri-build [RUST]: 2.0.0-alpha.12
    - wry [RUST]: 0.34.2
    - tao [RUST]: 0.23.0
    - @tauri-apps/api [NPM]: 2.0.0-alpha.12
    - @tauri-apps/cli [NPM]: 2.0.0-alpha.18

[-] App
    - build-type: bundle
    - CSP: unset
    - distDir: ../dist
    - devPath: http://localhost:3000/
    - framework: React (Next.js)
    - bundler: Vite

Stack trace

No response

Additional context

No response

amrbashir commented 10 months ago

I think that's because on macOS/Linux the PATH environment variable is not inherited by default from your .bashrc and similar shell files, can you try using this crate https://github.com/tauri-apps/fix-path-env-rs and see if it fixes the issue?

martin-opensky commented 10 months ago

@amrbashir thanks for the speedy response! I’m new to the Rust ecosystem, coming from TypeScript. Could you point me in the right direction for when you say ‘use this crate’?

amrbashir commented 10 months ago

A crate for Rust is like a NPM package for Javascript/Typescript, also you can find the instructions in the README.md in https://github.com/tauri-apps/fix-path-env-rs

martin-opensky commented 10 months ago

Thanks for the info. I’m away today but will take a look on Monday and will update you here.

martin-opensky commented 10 months ago

@amrbashir This doesn't appear to work.

When I update my main.rs with the code mentioned here (https://github.com/tauri-apps/fix-path-env-rs) all of my plugins stop working.

So to be clear, I replace:

fn main() { tauri_app_lib::run() }

with

fn main() { let _ = fix_path_env::fix(); tauri::Builder::default() .run(tauri::generate_context!()) .expect("Failed to run Tauri application"); }

And when I do this, the app builds but even the dialog plugin stops working...

Xnapper-2023-12-18-13 58 38
martin-opensky commented 10 months ago

@amrbashir I fixed the issue - apologies I am new to Rust.

The fix was:

fn main() { let _ = fix_path_env::fix(); tauri_app_lib::run() }

But this is not in the https://github.com/tauri-apps/fix-path-env-rs repo, so perhaps this needs to be updated for Tauri v2?

amrbashir commented 10 months ago

Looks like you are using tauri 2.0.0-alpha template with mobile support which has a different structure than normal template. I will update the README to make it more general.