tauri: [bug] Tauri resources work in dev but not build
Describe the bug
I have added a folder created with pyinstaller to my resources, then I use command::new() to run the main binary inside this folder. When I use cargo tauri dev everything works fine, but when I run cargo tauri build I get the below error:
Reproduction
Add in the resources item below, then try to run cargo tauri build (cargo tauri dev runs fine):
{
"build": {
"beforeDevCommand": "npm run dev",
"beforeBuildCommand": "npm run build",
"devPath": "http://localhost:1420",
"distDir": "../dist"
},
"package": {
"productName": "Application",
"version": "0.0.0"
},
"tauri": {
"allowlist": {
"all": true
},
"bundle": {
"active": true,
"category": "Finance",
"copyright": "",
"deb": {
"depends": []
},
"externalBin": [],
"icon": [
"icons/32x32.png",
"icons/128x128.png",
"icons/128x128@2x.png",
"icons/icon.icns",
"icons/icon.ico"
],
"identifier": "",
"longDescription": "",
"macOS": {
"entitlements": null,
"exceptionDomain": "",
"frameworks": [],
"providerShortName": null,
"signingIdentity": null
},
"resources": ["/Users/colindelahunty/terminalpro-poc/src-tauri/pyfolder/*"],
"shortDescription": "",
"targets": "all",
"windows": {
"certificateThumbprint": null,
"digestAlgorithm": "sha256",
"timestampUrl": ""
}
},
"security": {
"csp": null
},
"updater": {
"active": false
},
"windows": [
{
"fullscreen": false,
"height": 800,
"resizable": true,
"title": "Application",
"width": 1000
}
]
}
}
Expected behavior
I would expect cargo to function the same in dev and build.
Platform and versions
Environment › OS: Mac OS 13.0.0 X64 › Node.js: 19.1.0 › npm: 8.19.3 › pnpm: Not installed! › yarn: 1.22.19 › rustup: 1.25.1 › rustc: 1.65.0 › cargo: 1.65.0 › Rust toolchain: stable-aarch64-apple-darwin
Stack trace
No response
Additional context
I know technically I should use pyinstaller onefile, and then use sidecar, BUT my program is really big. Using --onefile brings the time the application has to wait before it starts running from 8 seconds to 84 seconds, which is something I would like to avoid.
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 1
- Comments: 15 (6 by maintainers)
@amrbashir I’m using
resolveResourcesee first code snippet. Theconsole.logmessage shows the correct path to the file. It’s just when building, looks like the app enforce something that makes the binary losses context access to path. Can’t find out what’s going on, I’ve even allowed access to everything from the tauri config file.So it actually works now, but still shows the same error which is weird. Should I just ignore the error, or could this cause issues in the future? Also, if I run in verbose mode no error is thrown.
Output of
cargo tauri build(error, but everything works):Output of `cargo tauri build --verbose (no error, everything works):