You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Error: PROJECT_NAME_FOR_VERSION_STRING environment variable not defined at compile time when installing coreutils #7992
First of all, thank you for providing this very useful tool!
When trying to install coreutils on Ubuntu 24.04 (WSL2), the build fails due to a missing environment variable.
Environment
OS
Ubuntu 24.04 under WSL2 on Windows 11
Rust version (use stable)
cargo 1.87.0 (99624be96 2025-05-06)
rustc 1.87.0 (17067e9ac 2025-05-09)
Reproduce
Run install command: cargo install coreutils --locked
Expected Behavior
coreutils should compile and install successfully.
cargo install coreutils --locked
Updating crates.io index
Installing coreutils v0.1.0
Updating crates.io index
Updating crates.io index
Compiling libc v0.2.172
# ...
Compiling uu_unlink v0.1.0
error: environment variable `PROJECT_NAME_FOR_VERSION_STRING` not defined at compile time
--> /home/hawk-tomy/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/uu_base32-0.1.0/src/base_common.rs:107:18
|
107 | .version(uucore::crate_version!())
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: use `std::env::var("PROJECT_NAME_FOR_VERSION_STRING")` to read the variable at run time
= note: this error originates in the macro `env` which comes from the expansion of the macro `uucore::crate_version` (in Nightly builds, run with -Z macro-backtrace for more info)
# ...
error: failed to compile `coreutils v0.1.0`, intermediate artifacts can be found at `/tmp/cargo-install95GA05`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
Thank you for your help!
Reacted by Theo, Sam Vendittelli, Stefan Lindblad, Matt Anger, Anurag Dhadse, Theo Paris, IchHabeKeineNamen, Stephen Doyle, skygunner, Igor Potseluev and 4 more
I also experienced the same issue today while updating on openSUSE Tumbleweed 20250601.
error: environment variable PROJECT_NAME_FOR_VERSION_STRINGnot defined at compile time --> /home/dad/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/uu_yes-0.1.0/src/yes.rs:41:18 | 41 | .version(uucore::crate_version!()) | ^^^^^^^^^^^^^^^^^^^^^^^^ | = help: usestd::env::var("PROJECT_NAME_FOR_VERSION_STRING")to read the variable at run time = note: this error originates in the macroenvwhich comes from the expansion of the macrouucore::crate_version` (in Nightly builds, run with -Z macro-backtrace for more info)
`
Setting environment variable allowed me to finish compiling the update
can reproduce on my linux fedora 42 machine with cargo install coreutils and cargo install coreutils --features unix --locked, the workaround did work for me
I'll give it a try. A simple way to reproduce (because of rust-lang/cargo#2930 ):
git clone https://github.com/uutils/coreutils.git
mkdir test && cd test
cargo build --manifest-path=../coreutils/Cargo.toml
Activity
cakebaker commentedon May 26, 2025
I can reproduce it on my machine.
A workaround is to use:
0x4D5352 commentedon May 26, 2025
I was also able to reproduce this on an M1 Mac Studio @ os 15.5, @cakebaker's fix worked.
sylvestre commentedon May 26, 2025
I am curious to know what changed on our side for this regression ?!
cakebaker commentedon May 26, 2025
@sylvestre it's a new feature I implemented in #7441
vDorst commentedon May 27, 2025
Same happens on Win 11.
Setting the env variable fixes it.
lashomb commentedon May 27, 2025
Also hit this on an M3 Macbook Pro running 15.5.
Fairglow commentedon May 29, 2025
I see the same problem on Arch Linux, but the work-around above solved it. Using same Rust versions as OP.
sylvestre commentedon May 29, 2025
@cakebaker can we fix it in the repo directly? Thanks
cakebaker commentedon May 29, 2025
@sylvestre it looks like it's a bug/feature in
cargo: rust-lang/cargo#14001, and we have to look for a different approach :|Ecordonnier commentedon May 29, 2025
I can send a fix, unless you're already working on it. I need such a configuration mechanism for a PR anyway.
kenmac999 commentedon Jun 3, 2025
I also experienced the same issue today while updating on openSUSE Tumbleweed 20250601.
error: environment variablePROJECT_NAME_FOR_VERSION_STRINGnot defined at compile time --> /home/dad/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/uu_yes-0.1.0/src/yes.rs:41:18 | 41 | .version(uucore::crate_version!()) | ^^^^^^^^^^^^^^^^^^^^^^^^ | = help: usestd::env::var("PROJECT_NAME_FOR_VERSION_STRING")to read the variable at run time = note: this error originates in the macroenvwhich comes from the expansion of the macrouucore::crate_version` (in Nightly builds, run with -Z macro-backtrace for more info)`
Setting environment variable allowed me to finish compiling the update
Finishedreleaseprofile [optimized] target(s) in 50.40s Replacing /home/dad/.cargo/bin/coreutils Replaced packagecoreutils v0.0.30withcoreutils v0.1.0(executablecoreutils)sylvestre commentedon Jun 11, 2025
@Ecordonnier don't hesitate for the fix :)
melMass commentedon Jul 5, 2025
Yep this is still a thing,
cargo install --locked coreutilsproduce this error on arm64 mac and on windowsseafiish commentedon Jul 17, 2025
can reproduce on my linux fedora 42 machine with
cargo install coreutilsandcargo install coreutils --features unix --locked, the workaround did work for meEcordonnier commentedon Jul 20, 2025
I'll give it a try. A simple way to reproduce (because of rust-lang/cargo#2930 ):