#I cant `use tauri::api::process::Command`

23 messages · Page 1 of 1 (latest)

proper stump
#

here is what the rust compiler shows:

PS C:\MyX-C5\libp2pProjects\SmoothHeatChat\SmoothChatHeat1> cargo tauri dev
        Info Watching C:\MyX-C5\libp2pProjects\SmoothHeatChat\SmoothChatHeat1\src-tauri for changes...
   Compiling SmoothChatHeat1 v0.0.0 (C:\MyX-C5\libp2pProjects\SmoothHeatChat\SmoothChatHeat1\src-tauri)
error[E0432]: unresolved import `tauri::api::process::Command`
 --> src\main.rs:4:5
  |
4 | use tauri::api::process::Command;
  |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no `Command` in `api::process`
  |
help: consider importing one of these items instead
  |
4 | use std::process::Command;
  |     ~~~~~~~~~~~~~~~~~~~~~
4 | use tauri::api::Error::Command;
  |     ~~~~~~~~~~~~~~~~~~~~~~~~~~

For more information about this error, try `rustc --explain E0432`.
error: could not compile `SmoothChatHeat1` due to previous error
echo flint
#

It's hidden behind a feature flag process-command-api which the tauri cli will remove automatically if you don't allowlist it in tauri.conf.josn

#

which, of course is not that nice because it will also allowlist it for the js side

proper stump
#

so I should add that to cargo toml and enable in the allowlist the command?

echo flint
#

changing the allowlist is enough, the cli will add the feature flag

proper stump
#

ok thank you very much!

echo flint
#

you can also just use rust's Command. There isn't that much of a difference but you'd potentially have to kill the Child on exit yourself

proper stump
#

hey I used the std command but with VSCode running in the terminal cargo tauri dev it spawns the powershell inside the same terminal? how to open with command an external powershell?

#

I want to spawn two powershells so they can make a chat together, the code works have tested it before trying to implement it in tauri

echo flint
#

If you want both powershell windows to actually exist you can try something like this: rs use std::os::windows::process::CommandExt; let cmd = Command::new().creation_flags(0x00000010) // CREATE_NEW_CONSOLE if you want to hide them: ```rs
use std::os::windows::process::CommandExt;
let cmd = Command::new().creation_flags(0x08000000) // CREATE_NO_WINDOW

ref: <https://doc.rust-lang.org/std/os/windows/process/trait.CommandExt.html#tymethod.creation_flags>
proper stump
#

thanks!

#

shouldnt it be CommandExt::new?

#

but there is an error there

#

that new doesnt exits

echo flint
#

CommandExt "extends" std::process::Command

proper stump
#

how to run powershell then?

#

oh so I need also use std::process::Command?

echo flint
#

yea

proper stump
#

okok

#

brb

#

it works!!! briliant!!!

#

thanks a lot!!!