mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-04-01 10:01:07 +02:00
committed by
GitHub
parent
38f5db6e6a
commit
e0e5f77243
6
.changes/cargo-not-found.md
Normal file
6
.changes/cargo-not-found.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"cli.rs": patch
|
||||
"cli.js": patch
|
||||
---
|
||||
|
||||
Improve error message when `cargo` is not installed.
|
||||
@@ -23,7 +23,7 @@ use std::{
|
||||
env::set_current_dir,
|
||||
ffi::OsStr,
|
||||
fs::FileType,
|
||||
io::{BufReader, Write},
|
||||
io::{BufReader, ErrorKind, Write},
|
||||
path::{Path, PathBuf},
|
||||
process::{exit, Command, Stdio},
|
||||
sync::{
|
||||
@@ -495,8 +495,24 @@ fn start_app(
|
||||
command.stdout(os_pipe::dup_stdout().unwrap());
|
||||
command.stderr(Stdio::piped());
|
||||
|
||||
let child =
|
||||
SharedChild::spawn(&mut command).with_context(|| format!("failed to run {}", runner))?;
|
||||
let child = match SharedChild::spawn(&mut command) {
|
||||
Ok(c) => c,
|
||||
Err(e) => {
|
||||
if e.kind() == ErrorKind::NotFound {
|
||||
return Err(anyhow::anyhow!(
|
||||
"`{}` command not found.{}",
|
||||
runner,
|
||||
if runner == "cargo" {
|
||||
" Please follow the Tauri setup guide: https://tauri.app/v1/guides/getting-started/prerequisites"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
));
|
||||
} else {
|
||||
return Err(e.into());
|
||||
}
|
||||
}
|
||||
};
|
||||
let child_arc = Arc::new(child);
|
||||
let child_stderr = child_arc.take_stderr().unwrap();
|
||||
let mut stderr = BufReader::new(child_stderr);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
use std::{
|
||||
fs::File,
|
||||
io::Read,
|
||||
io::{ErrorKind, Read},
|
||||
path::{Path, PathBuf},
|
||||
process::Command,
|
||||
str::FromStr,
|
||||
@@ -101,18 +101,37 @@ struct CargoConfig {
|
||||
}
|
||||
|
||||
pub fn build_project(runner: String, args: Vec<String>) -> crate::Result<()> {
|
||||
let status = Command::new(&runner)
|
||||
match Command::new(&runner)
|
||||
.args(&["build", "--features=custom-protocol"])
|
||||
.args(args)
|
||||
.env("STATIC_VCRUNTIME", "true")
|
||||
.piped()?;
|
||||
if status.success() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(anyhow::anyhow!(
|
||||
"Result of `{} build` operation was unsuccessful",
|
||||
runner
|
||||
))
|
||||
.piped()
|
||||
{
|
||||
Ok(status) => {
|
||||
if status.success() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(anyhow::anyhow!(
|
||||
"Result of `{} build` operation was unsuccessful",
|
||||
runner
|
||||
))
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
if e.kind() == ErrorKind::NotFound {
|
||||
Err(anyhow::anyhow!(
|
||||
"`{}` command not found.{}",
|
||||
runner,
|
||||
if runner == "cargo" {
|
||||
" Please follow the Tauri setup guide: https://tauri.app/v1/guides/getting-started/prerequisites"
|
||||
} else {
|
||||
""
|
||||
}
|
||||
))
|
||||
} else {
|
||||
Err(e.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -176,12 +176,12 @@ fn prettyprint_level(lvl: Level) -> &'static str {
|
||||
pub trait CommandExt {
|
||||
// The `pipe` function sets the stdout and stderr to properly
|
||||
// show the command output in the Node.js wrapper.
|
||||
fn piped(&mut self) -> Result<ExitStatus>;
|
||||
fn piped(&mut self) -> std::io::Result<ExitStatus>;
|
||||
fn output_ok(&mut self) -> crate::Result<()>;
|
||||
}
|
||||
|
||||
impl CommandExt for Command {
|
||||
fn piped(&mut self) -> crate::Result<ExitStatus> {
|
||||
fn piped(&mut self) -> std::io::Result<ExitStatus> {
|
||||
self.stdout(os_pipe::dup_stdout()?);
|
||||
self.stderr(os_pipe::dup_stderr()?);
|
||||
let program = self.get_program().to_string_lossy().into_owned();
|
||||
|
||||
Reference in New Issue
Block a user