#sidecar not found / build failes

6 messages · Page 1 of 1 (latest)

zealous citrus
#

Docs: https://tauri.app/v1/guides/building/sidecar/

I have a binary I want to use as side car. Its a nodejs script build with pkg. The name is ftpSidecar-x86_64-apple-darwin-x86_64-apple-darwin. I am on macos.

my tauri.conf.json contains the necessary allowlist and bundle entries:
`...
"shell": {
"sidecar": true,
"scope": [
{ "name": "src-tauri/sidecars/ftpSidecar-x86_64-apple-darwin", "sidecar": true, "args":["arg0"] }
]
},

...
"bundle": {
"active": true,
"category": "DeveloperTool",
"copyright": "",
"deb": {
"depends": []
},
"externalBin": ["src-tauri/sidecars/ftpSidecar-x86_64-apple-darwin"],
...`

In my frontend code I import the tauri shell api and execute the command as documented:
import { Command } from '@tauri-apps/api/shell' ... const command = Command.sidecar('src-tauri/sidecars/ftpSidecar-x86_64-apple-darwin',[dataBody]) const output = await command.execute() ...

When I build the app, I get this error stating that tauri doesnt find the binary:
error: failed to run custom build command for`app v0.1.0 (/Users/me/dev/taurisveltekit/src-tauri)

Caused by:
process didn't exit successfully: /Users/me/dev/taurisveltekit/src-tauri/target/debug/build/app-b3b9f8db6a9f8b3d/build-script-build (exit status: 1) --- stdout cargo:rerun-if-env-changed=TAURI_CONFIG cargo:rerun-if-changed=tauri.conf.json cargo:rustc-cfg=desktop cargo:rustc-cfg=dev path matching src-tauri/sidecars/ftpSidecar-x86_64-apple-darwin-x86_64-apple-darwin not found. warning: build failed, waiting for other jobs to finish...

I've already tried the full path instead of the relative path, but it resulted in the same error.
What am I missing?

You may need to embed depending binaries to make your application work or prevent users from installing additional dependencies (e.g., Node.js or Python).

odd fox
#

Try removing the x86_64... stuff from externalBin, the scope, and the js code. It's only relevant in the filename itself

zealous citrus
#

Hell yes it works! 😻

zealous citrus
#

Hey, I have a follow-up question. I want to pass an argument without actually passing a flag. What do I need to specify in my config?

"tauri": { "allowlist": { "shell": { "sidecar": true, "scope": [ { "name": "sidecars/ftpSidecar", "sidecar": true, "args":[""] } ] },

Also, if I decide to use a flag like --config, what do I need to define in my args array in the command? Would it be something like
Command.sidecar('sidecars/ftpSidecar', ["--config",dataBody]); ?
In this case, dataBody is a string variable.
I know this is documented but its not really clear to me.

odd fox
#

tbh I'd just set "args": true for sidecars.

But in general if you know the exact value of an arg beforehand, like --config then you write a string with that value. If the value is variable then you need the validator thing briefly shown somewhere in the docs. It takes a regex which should be somewhat easy to google, but imo for args validation it can get quite tricky to make something other than .+ working for non plain-string args