Skip to content

uucore not rebuilding when adding new utility for translate! and missing its locales #13691

Description

@dmatos2012

Hi,
Recently, I pushed a PR to use uu_ln in Nushell which had to be reverted because tests didnt pass on macos. You can see a description of what we found.

MRE

cargo new mre --vcs=none
cd mre

Important: make sure to set your cargo_home to a tmp or
any non default directory, otherwise it might use your cached artifactss

export CARGO_HOME=/tmp/.cargo/

Add uucore and fluent and leave ln on purpose out

cargo add uucore uu_cp fluent

You must add a random utility, uu_cp does the job.

Use this as your src/main.rs:

use uucore::translate;
fn main() {
    let _ = uucore::localized_help_template("ln");
    let msg = translate!("ln-error-missing-destination", "operand" => "foo");
    if msg.contains("ln-error-missing-destination") {
        eprintln!("Error is is: {msg}. Utility not localized properly");
    } else {
        eprintln!("Got translation: {msg}");
    }
}

Build initially and run it

cargo r

As expected uu_ln doesnt work because it wasnt added to our deps.
Add uu_ln

cargo add uu_ln

Expected: it works

cargo r

Still not working.

Msg is: ln-error-missing-destination. Utility not localized properly

Now to fix it, we force uucore to rebuild:

cargo clean -p uucore

Rerun cargo r:

Got translation: missing destination file operand after foo

Im guessing a fix could be either a new re-run-if-env-changed on build.rs, or some sort of hash on registry directory which can be then recalculated to know if something has changed, but im no expert.

Thanks for your great work!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions