tauri-docs
tauri-docs copied to clipboard
[request] Sidecar docs – example does not work in rust.
Question you want answered
Update the side car docs with a recent example.
Where did you look for an answer?
Page URL
https://tauri.app/learn/sidecar-nodejs/
Additional context
No response
Are you willing to work on this yourself?
- [ ] I want to work on this myself
Also it would help to elaborate how where to add this:
import { execSync } from 'child_process';
import fs from 'fs';
const ext = process.platform === 'win32' ? '.exe' : '';
const rustInfo = execSync('rustc -vV');
const targetTriple = /host: (\S+)/g.exec(rustInfo)[1];
if (!targetTriple) {
console.error('Failed to determine platform target triple');
}
fs.renameSync(
`app${ext}`,
`../src-tauri/binaries/app-${targetTriple}${ext}`
);
I'm assuming it's the package that I created.
Trying the JS example, I get this error.
const message = "Tauri";
const command = Command.sidecar("binaries/app", ["ping", message]);
const output = await command.execute();
const response = output.stdout;
console.log(response);
no method named
shellfound for structAppHandle
The example is omitting the imports (either by accident or intentionally). The Quick Fix suggestions in your screenshot should have worked. It should add use tauri_plugin_shell::ShellExt;
Also it would help to elaborate how where to add this:
It's a standalone javascript file (name doesn't matter), that you'd execute with node thatfile.js
Trying the JS example, I get this error.
Like the note at the top of the page says, the guide assumes you followed the shell guide. Here you're missing the rust changes https://tauri.app/plugin/shell/#setup (manual tab)
Not disagreeing btw, the guide needs improvements.
thanks @FabianLars, I got it working. Let me see if I can make a PR.