How to open VS Code with a Tauri App? #5053
-
Hi all, I'm developing a new Tauri app that lets me open a VS Code codespace with a given path. I'm doing like: if (isWeb()) return
const path = repo?.value?.repo.path
if (!path) {
toast.add('Path has not been configured', 'Error', undefined, 2)
return
}
const cmd = new Command('code', path)
// const cmd = new Command('code', '.', { cwd: path })
cmd.on('error', () => {
toast.add('Opening repo in Vs Code failed!', 'Error', OPEN_VSCODE_TOAST_ID, 2)
})
await cmd.spawn().catch((e) => {
alert(e)
}) My tauri config for that is {
"name": "code",
"cmd": "code",
"args": true
} What I have received is Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
The problem with vscode in particular is that what's added to the PATH var is not the exe itself, but a cmd script. This means that, at least on windows, you have to explicitly call that file by changing the scope config's cmd to |
Beta Was this translation helpful? Give feedback.
The problem with vscode in particular is that what's added to the PATH var is not the exe itself, but a cmd script. This means that, at least on windows, you have to explicitly call that file by changing the scope config's cmd to
"cmd": "code.cmd"
.On Linux/macos it's a bit tricky since the bundled app packages don't even have inherit the PATH from shell dotfile (you can regain access to it via this crate https://github.com/tauri-apps/fix-path-env-rs). But on these platforms you probably would invoke the equivalent to
sh -c "code path"
to start vscode (which should work on windows too btw)