Skip to content

Error: cargo install coreutils --features windows fails on Windows due to stdbuf #13886

Closed

Description

@hawk-tomy

Thank you so much for this amazing software, and thanks for supporting Windows too!!
When trying to install coreutils(v0.10.0) on windows, the build fails due to a missing environment variable.

Environment

  • OS
    • Windows 11
  • Rust version (use stable)
    • cargo 1.97.1 (c980f4866 2026-06-30)
    • rustc 1.97.1 (8bab26f4f 2026-07-14)

Reproduce

Run install command on Windows in PowerShell.
cargo install coreutils --features windows --locked

Problem

The build fails while compiling uu_stdbuf:

error: environment variable `LIBSTDBUF_DIR` not defined at compile time
   --> %home%\.cargo\registry\src\index.crates.io-1949cf8c6b5b557f\uu_stdbuf-0.10.0\src\stdbuf.rs:152:33
    |
152 |     const LIBSTDBUF_DIR: &str = env!("LIBSTDBUF_DIR");
    |                                 ^^^^^^^^^^^^^^^^^^^^^
    |
    = help: use `std::env::var("LIBSTDBUF_DIR")` to read the variable at run time

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

Suspected cause

This issue appears to be a side effect of #12329.

That PR added stdbuf to the Windows feature set to support stdbuf.exe via libstdbuf.dll (built for Cygwin/MSYS2). However, this change inadvertently enables stdbuf by default during installation, even for users who aren't targeting Cygwin/MSYS2.

On Windows, this triggers the external libstdbuf code path, which expects LIBSTDBUF_DIR to be set at compile time. Since this variable is missing when installing from crates.io, the build fails.

Expected behavior

cargo install coreutils --features windows --locked should work for a normal Windows installation without requiring Cygwin/MSYS2-specific libstdbuf configuration.

Activity

  1. oech3 commented on Aug 12, 2026

    @oech3
    Contributor

    It iws expected. Windows native stdbuf.exe depends on Cygwin libstdbuf.dll. Defult value for LIBSTDBUF_DIR is provided at https://github.com/uutils/coreutils/blob/main/.cargo/config.toml .

  2. hawk-tomy commented on Aug 12, 2026

    @hawk-tomy
    Author

    Thanks for the clarification.

    As was already encountered in #7992, relying on values from the repository's .cargo/config.toml does not work when installing from crates.io with cargo install, so LIBSTDBUF_DIR is not defined in this case.

    Also, I am a native Windows user and do not use Cygwin. I would expect the general windows feature not to assume that Cygwin is installed or configured. (I understand that coreutils doesn't particularly require Cygwin.)

  3. oech3 commented on Aug 12, 2026

    @oech3
    Contributor

    This is needed for people still want to use Windows native binary on MSYS2 if possible. Also needed to protect against build failure. I'll switch to option_env!("LIBSTDBUF_DIR").

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions