From c6119934d889235e36f545caef197bd2c540f4b6 Mon Sep 17 00:00:00 2001 From: Etienne Cordonnier Date: Sun, 20 Jul 2025 23:00:23 +0200 Subject: [PATCH] remove PROJECT_NAME_FOR_VERSION_STRING This fixes out-of-tree builds which are using --manifest-path and ignoring .cargo/config.toml because of https://github.com/rust-lang/cargo/issues/2930 : ``` git clone https://github.com/uutils/coreutils.git mkdir test && cd test cargo build --manifest-path=../coreutils/Cargo.toml ``` This also fixes installation of coreutils from crates.io, which also ignores .cargo/config.toml: ``` cargo install coreutils --locked ``` Using `option_env` is not possible because `concat!` needs a string literal. I don't see a need to change the project name using an environment variable, so let's keep things simple and simply remove it to fix this bug. Fixes https://github.com/uutils/coreutils/issues/7992 Signed-off-by: Etienne Cordonnier --- .cargo/config.toml | 5 ++++- src/uucore/src/lib/lib.rs | 10 +--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/.cargo/config.toml b/.cargo/config.toml index 33eb2be52b4..d409506399e 100644 --- a/.cargo/config.toml +++ b/.cargo/config.toml @@ -1,8 +1,11 @@ +# Note: keep in mind that this file is completely ignored in several use-cases +# like e.g. out-of-tree builds ( https://github.com/rust-lang/cargo/issues/2930 ). +# For this reason this file should be avoided as much as possible when there are alternatives. + [target.x86_64-unknown-redox] linker = "x86_64-unknown-redox-gcc" [env] -PROJECT_NAME_FOR_VERSION_STRING = "uutils coreutils" # See feat_external_libstdbuf in src/uu/stdbuf/Cargo.toml LIBSTDBUF_DIR = "/usr/local/libexec/coreutils" diff --git a/src/uucore/src/lib/lib.rs b/src/uucore/src/lib/lib.rs index 6cebe5e3c45..cde28863946 100644 --- a/src/uucore/src/lib/lib.rs +++ b/src/uucore/src/lib/lib.rs @@ -205,18 +205,10 @@ macro_rules! bin { /// /// The generated string has the format `() `, for /// example: "(uutils coreutils) 0.30.0". clap will then prefix it with the util name. -/// -/// To use this macro, you have to add `PROJECT_NAME_FOR_VERSION_STRING = ""` to the -/// `[env]` section in `.cargo/config.toml`. #[macro_export] macro_rules! crate_version { () => { - concat!( - "(", - env!("PROJECT_NAME_FOR_VERSION_STRING"), - ") ", - env!("CARGO_PKG_VERSION") - ) + concat!("(uutils coreutils) ", env!("CARGO_PKG_VERSION")) }; }