Skip to content

Commit

Permalink
Remove anyhow dependency in uvx (#6347)
Browse files Browse the repository at this point in the history
## Summary

This is now unused.
  • Loading branch information
charliermarsh authored Aug 21, 2024
1 parent 90df56f commit fd408c4
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions crates/uv/src/bin/uvx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,13 @@ use std::{
process::{Command, ExitCode, ExitStatus},
};

use anyhow::{bail, Error};

/// Spawns a command exec style.
fn exec_spawn(cmd: &mut Command) -> Result<Infallible, Error> {
fn exec_spawn(cmd: &mut Command) -> std::io::Result<Infallible> {
#[cfg(unix)]
{
use std::os::unix::process::CommandExt;
let err = cmd.exec();
Err(err.into())
Err(err)
}
#[cfg(windows)]
{
Expand All @@ -24,10 +22,13 @@ fn exec_spawn(cmd: &mut Command) -> Result<Infallible, Error> {
}
}

fn run() -> Result<ExitStatus, Error> {
fn run() -> std::io::Result<ExitStatus> {
let current_exe = std::env::current_exe()?;
let Some(bin) = current_exe.parent() else {
bail!("Could not determine the location of the `uvx` binary")
return Err(std::io::Error::new(
std::io::ErrorKind::NotFound,
"Could not determine the location of the `uvx` binary",
));
};
let uv = bin.join("uv");
let args = ["tool", "uvx"]
Expand All @@ -49,11 +50,7 @@ fn main() -> ExitCode {
// Fail with 2 if the status cannot be cast to an exit code
Ok(status) => u8::try_from(status.code().unwrap_or(2)).unwrap_or(2).into(),
Err(err) => {
let mut causes = err.chain();
eprintln!("error: {}", causes.next().unwrap());
for err in causes {
eprintln!(" Caused by: {err}");
}
eprintln!("error: {err}");
ExitCode::from(2)
}
}
Expand Down

0 comments on commit fd408c4

Please sign in to comment.