coreutils: Error: `PROJECT_NAME_FOR_VERSION_STRING` environment variable not defined at compile time when installing `coreutils`

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.

Actual Behavior

  • Compilation fails with multiple errors like:

Full log: https://gist.github.com/hawk-tomy/b03db482558db40dfab31085df5185bd

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!

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 13
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

I can reproduce it on my machine.

A workaround is to use:

PROJECT_NAME_FOR_VERSION_STRING="uutils coreutils" cargo install coreutils --locked