Skip to content

uucore translations are once per-thread, which can lead to untranslated error names #19004

Open

Description

@pickx

Bug report form

  • I have done a basic search of the issue tracker to find any existing issues that are similar.
  • I have checked that my version is at least the latest stable release available via my installation method.

Describe the bug

disclaimer: based on my very shallow understanding of uutils. hopefully it's correct.

  • uucore has a translate! macro which uses localized names for error message ids
  • to use this, you first call an initializer with the name of the util. this initialization is thread local
  • so this system assumes one uucore util per thread
  • ...which nushell doesn't do
  • this means if it was already loaded for one util, an error for a different util in the same nu thread might give an untranslated error name

How to reproduce

both of these must start from a fresh session of nu

> mktemp foo
Error: nu::shell::error

  × too few X's in template 'foo'
   ╭────
 1 │ crates/nu-command/src/filesystem/mktemp.rs:119:48
   · ────────────────────────┬────────────────────────
   ·                         ╰── too few X's in template 'foo'
   ╰────

vs.

> uname | ignore
> mktemp foo
Error: nu::shell::error

  × mktemp-error-too-few-xs
   ╭────
 1 │ crates/nu-command/src/filesystem/mktemp.rs:119:48
   · ────────────────────────┬────────────────────────
   ·                         ╰── mktemp-error-too-few-xs
   ╰────

Expected behavior

calling uname before mktemp should not affect mktemp's translations

Configuration

key value
version 0.115.2
major 0
minor 115
patch 2
branch master
commit_hash 9cb59b9
build_os macos-aarch64
build_target aarch64-apple-darwin
rust_version rustc 1.98.0 (88d9e12ae 2026-08-18)
rust_channel stable-aarch64-apple-darwin
cargo_version cargo 1.98.0 (797e8a9bc 2026-08-05)
build_time 2026-09-10 13:37:52 +03:00
build_rust_channel release
allocator standard
features default, lsp, mcp, network, plugin, rustls-tls, sqlite, trash-support
installed_plugins desktop_notifications 0.107.0, formats 0.107.0, highlight 1.4.9+0.107.0, json_path 0.17.1, query 0.107.0, regex 0.19.0, skim 0.22.0, strutils 0.21.0
experimental_options example=false, dc-glob=true, reorder-cell-paths=true, pipefail=true, enforce-runtime-annotations=true, native-clip=true, cell-path-types=true

Activity

  1. aakarshitv commented on Oct 3, 2026

    @aakarshitv
    Contributor

    I looked into this. The cause is in uucore, so nushell can't fix it on its side. In uucore/src/lib/mods/locale.rs, both levels keep whichever util was set up first:

    • setup_localization() returns early once any util has been set up on the current thread, so a later localized_help_template("mktemp") does nothing.
    • In the embedded-locale path, which nushell uses, each util's strings are cached in a single process-wide UTIL_FLUENT: OnceLock. So even a fresh thread gets the first util's strings: [1] | par-each {|_| uname | ignore }; mktemp foo also prints mktemp-error-too-few-xs.

    The error types call translate! in their Display impls, so there's nothing to route around in nushell. I tested a small uucore patch (a per-util cache, and rebuilding the thread's localizer when the util changes) through [patch.crates-io]. With it, all of the cases above print the translated message.

    I've opened uutils/coreutils#15040 upstream with the repro and proposed fix, and I'll bump uucore here once it lands. Separately, platform/whoami.rs passes "touch" to localized_help_template. I'll fix that in a small PR.

  2. fdncred commented on Oct 3, 2026

    @fdncred
    Contributor

    Thanks. I assume someone will have to submit a PR to get it fixed. Do you have time to do that?

  3. aakarshitv commented on Oct 3, 2026

    @aakarshitv
    Contributor

    Yes, I'm down to work on that

  4. aakarshitv commented on Oct 3, 2026

    @aakarshitv
    Contributor

    Opened both:

    Once uutils/coreutils#15044 is merged and released, nushell just needs a uucore bump.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    status:needs-triageAn issue that hasn't had any proper look

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions