From f2b82bef7e651ba9f0b5871bb5d8d04adb70d960 Mon Sep 17 00:00:00 2001 From: Sebastian Nagel Date: Tue, 10 Mar 2026 21:38:48 +0100 Subject: [PATCH] feat: look up tools on PATH --- CHANGELOG.md | 4 ++++ Cargo.lock | 25 +++++++++++++++++++++++++ Cargo.toml | 3 ++- src/home.rs | 11 ++++++++--- 4 files changed, 39 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a040a2..22a9455 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ All notable changes to this project will be documented in this file. +## [0.20.1] - UNRELEASED + +- Look on PATH for tools (e.g. tx3c) + ## [0.20.0] - 2026-02-14 ### 🚀 Features diff --git a/Cargo.lock b/Cargo.lock index c3b21f7..1e16d9d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1178,6 +1178,12 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "env_home" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7f84e12ccf0a7ddc17a6c41c93326024c42920d7ee630d04950e6926645c0fe" + [[package]] name = "equivalent" version = "1.0.2" @@ -4413,6 +4419,7 @@ dependencies = [ "tx3-lang", "tx3-tir", "utxorpc", + "which", "zip", ] @@ -4745,6 +4752,18 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "which" +version = "7.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d643ce3fd3e5b54854602a080f34fb10ab75e0b813ee32d00ca2b44fa74762" +dependencies = [ + "either", + "env_home", + "rustix", + "winsafe", +] + [[package]] name = "winapi" version = "0.3.9" @@ -5067,6 +5086,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "winsafe" +version = "0.0.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904" + [[package]] name = "wit-bindgen-rt" version = "0.39.0" diff --git a/Cargo.toml b/Cargo.toml index 5ed8a6c..3519aea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "trix" description = "The Tx3 package manager" -version = "0.20.0" +version = "0.20.1" edition = "2024" repository = "https://github.com/tx3-lang/trix" homepage = "https://github.com/tx3-lang/trix" @@ -57,6 +57,7 @@ tracing = "0.1" tokio-util = "0.7" tracing-subscriber = "0.3.22" dotenv-parser = "0.1.3" +which = "7" termimad = "0.31" [dev-dependencies] diff --git a/src/home.rs b/src/home.rs index 30d37f3..234221e 100644 --- a/src/home.rs +++ b/src/home.rs @@ -64,10 +64,15 @@ pub fn custom_tool_path(name: &str) -> miette::Result> { } pub fn tool_path(name: &str) -> miette::Result { - match custom_tool_path(name)? { - Some(path) => Ok(path), - None => default_tool_path(name), + if let Some(path) = custom_tool_path(name)? { + return Ok(path); } + + if let Ok(path) = which::which(name) { + return Ok(path); + } + + default_tool_path(name) } #[allow(dead_code)]