Skip to content

Conversation

@rynewang
Copy link
Contributor

@rynewang rynewang commented Jan 3, 2026

Move the tldr.zip missing warning from runtime (uudoc.rs) to compile time (build.rs). This ensures the warning is printed only once during the build, instead of 100+ times when make calls uudoc separately for each utility.

The Problem

From issue #9940:

Calling this for all utils pollutes the build log. No need to show it 100+ times.

The previous OnceLock approach did not work because make install-manpages invokes uudoc manpage <utility> as a separate process for each utility. Since each process has its own memory, OnceLock resets every time.

The Fix

Check for docs/tldr.zip in build.rs and emit a cargo:warning= message at compile time:

// build.rs
if env::var("CARGO_FEATURE_UUDOC").is_ok() && !Path::new("docs/tldr.zip").exists() {
    println!("cargo:warning=No tldr archive found, so the documentation will not include examples.");
    println!("cargo:warning=To include examples, download the tldr archive:");
    println!("cargo:warning=  curl -L https://github.com/tldr-pages/tldr/releases/latest/download/tldr.zip -o docs/tldr.zip");
}

This prints the warning exactly once when cargo build --features uudoc runs, not during the 100+ runtime invocations.

Testing

Build prints the warning once:

$ cargo build --bin uudoc --features "uudoc feat_os_unix"
   Compiling coreutils v0.5.0 (/workspace)
warning: coreutils@0.5.0: No tldr archive found, so the documentation will not include examples.
warning: coreutils@0.5.0: To include examples, download the tldr archive:
warning: coreutils@0.5.0:   curl -L https://github.com/tldr-pages/tldr/releases/latest/download/tldr.zip -o docs/tldr.zip
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 5.39s

Running uudoc manpage for multiple utilities (simulating make install-manpages) prints no warnings:

$ for util in ls cat cp mv rm mkdir rmdir echo head tail; do ./target/debug/uudoc manpage $util 2>&1 >/dev/null; done
(no output - no warnings printed!)

Fixes #9940

@sylvestre
Copy link
Contributor

Could you please add a test to verify this? Thanks

@oech3
Copy link
Contributor

oech3 commented Jan 4, 2026

Per process? make calls uudoc process for all utils. So this should be printed at build time (at build.rs).

@rynewang rynewang force-pushed the fix-uudoc-tldr-warning-once branch from 2d242c2 to 5af84b3 Compare January 4, 2026 17:38
@oech3

This comment was marked as resolved.

@rynewang
Copy link
Contributor Author

rynewang commented Jan 4, 2026

Hi

@sylvestre, since it's now in build.rs do I still need to do unit tests? What's the best way to do unit tests for build.rs? I made manual tests with cargo build as in updated description.

Move the tldr.zip missing warning from runtime (uudoc.rs) to compile
time (build.rs). This ensures the warning is printed only once during
the build, instead of 100+ times when make calls uudoc separately for
each utility.

Fixes uutils#9940
@rynewang rynewang force-pushed the fix-uudoc-tldr-warning-once branch from 5af84b3 to 83e37bb Compare January 4, 2026 17:43
@rynewang
Copy link
Contributor Author

rynewang commented Jan 4, 2026

@oech3 thanks, cargo fmted

@github-actions
Copy link

github-actions bot commented Jan 4, 2026

GNU testsuite comparison:

GNU test failed: tests/shuf/shuf-reservoir. tests/shuf/shuf-reservoir is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/sort/sort-stale-thread-mem. tests/sort/sort-stale-thread-mem is passing on 'main'. Maybe you have to rebase?

@rynewang
Copy link
Contributor Author

rynewang commented Jan 4, 2026

I tried to run both GNU tests locally and they passed, maybe it needs a retry?

@oech3
Copy link
Contributor

oech3 commented Jan 4, 2026

It is intermittent failure and merge main delays review.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build: Don't show tldr.zip is missing error for all utils

3 participants