Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[request] Sidecar docs – example does not work in rust. #3136

Open
1 task
gtokman opened this issue Jan 27, 2025 · 4 comments
Open
1 task

[request] Sidecar docs – example does not work in rust. #3136

gtokman opened this issue Jan 27, 2025 · 4 comments
Labels
discuss Does this require further discussion before it's dealt with? enhancement Does it add or improve content?

Comments

@gtokman
Copy link

gtokman commented Jan 27, 2025

Question you want answered

Update the side car docs with a recent example.

Where did you look for an answer?

Image

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
@gtokman gtokman added discuss Does this require further discussion before it's dealt with? enhancement Does it add or improve content? labels Jan 27, 2025
@gtokman
Copy link
Author

gtokman commented Jan 27, 2025

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.

@gtokman
Copy link
Author

gtokman commented Jan 27, 2025

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);

Image

@FabianLars
Copy link
Member

FabianLars commented Jan 27, 2025

no method named shell found for struct AppHandle

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.

@gtokman
Copy link
Author

gtokman commented Jan 27, 2025

thanks @FabianLars, I got it working. Let me see if I can make a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discuss Does this require further discussion before it's dealt with? enhancement Does it add or improve content?
Projects
None yet
Development

No branches or pull requests

2 participants