Skip to content

Bug Report: Type Mismatch Error in default_env.nu When Using format date '%x %X' #15266

Description

@Pantakit-Joseph

Describe the bug

When starting Nushell, a Type mismatch error occurs in default_env.nu at line 25, related to the format date '%x %X' command. The system reports it as an "invalid format"

~> nu
Error: nu::shell::type_mismatch

  × Type mismatch.
    ╭─[default_env.nu:25:33]
 24 │         (ansi magenta)
 25 │         (date now | format date '%x %X') # try to respect user's locale
    ·                                 ───┬───
    ·                                    ╰── invalid format
 26 │     ] | str join | str replace --regex --all "([/:])" $"(ansi green)${1}(ansi magenta)" |
    ╰────

Environment

OS: Fedora Linux 41 (Workstation Edition) x86_64
Nushell version: 0.102.0

~> locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC=th_TH.UTF-8
LC_TIME=th_TH.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=th_TH.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=th_TH.UTF-8
LC_NAME="en_US.UTF-8"
LC_ADDRESS=th_TH.UTF-8
LC_TELEPHONE=th_TH.UTF-8
LC_MEASUREMENT=th_TH.UTF-8
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=

How to reproduce

  1. Start Nushell using the nu command
  2. The system attempts to load default_env.nu which uses format date '%x %X' to display date and time according to user's locale
  3. A Type mismatch error occurs due to invalid format

Expected behavior

The command date now | format date '%x %X' should display date and time according to the user's locale settings without errors

Configuration

key value
version 0.102.0
major 0
minor 102
patch 0
branch
commit_hash 1aa2ed1
build_os linux-x86_64
build_target x86_64-unknown-linux-musl
rust_version rustc 1.82.0 (f6e511eec 2024-10-15)
rust_channel 1.82.0-x86_64-unknown-linux-gnu
cargo_version cargo 1.82.0 (8f40fc59f 2024-08-21)
build_time 2025-02-05 00:56:06 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, static-link-openssl, trash
installed_plugins

Activity

  1. fdncred commented on Mar 7, 2025

    @fdncred
    Contributor

    No issues on Windows with 0.102.1 (latest main branch/nightly)

    ❯ date now | format date '%x %X'
    03/07/2025 12:40:20 PM

    or on WSL Ubuntu with 0.102.1 (latest main branch/nightly)

    ❯ date now | format date '%x %X'
    03/07/2025 12:40:54 PM
    ❯ locale
    LANG=C.UTF-8
    LANGUAGE=
    LC_CTYPE="C.UTF-8"
    LC_NUMERIC="C.UTF-8"
    LC_TIME="C.UTF-8"
    LC_COLLATE="C.UTF-8"
    LC_MONETARY="C.UTF-8"
    LC_MESSAGES="C.UTF-8"
    LC_PAPER="C.UTF-8"
    LC_NAME="C.UTF-8"
    LC_ADDRESS="C.UTF-8"
    LC_TELEPHONE="C.UTF-8"
    LC_MEASUREMENT="C.UTF-8"
    LC_IDENTIFICATION="C.UTF-8"
    LC_ALL=
  2. sgvictorino commented on Mar 7, 2025

    @sgvictorino
    Contributor

    Reproduced on Linux (main):

    > $env.LC_TIME = "th_TH.UTF-8"
    Error: nu::shell::type_mismatch
    
      × Type mismatch.
        ╭─[default_env.nu:25:33]
     24 │         (ansi magenta)
     25 │         (date now | format date '%x %X') # try to respect user's locale
        ·                                 ───┬───
        ·                                    ╰── invalid format
  3. fdncred commented on Mar 7, 2025

    @fdncred
    Contributor

    It looks like it's just calling sys_locale::get_locale. Maybe there's a bug upstream with that crate? I guess you'd have to see what get_system_locale_string() is returning.

  4. sgvictorino commented on Mar 7, 2025

    @sgvictorino
    Contributor

    This seems to affect any locale that uses the %E modifier, which is unimplemented by chrono:

    > date now | format date %Ey
    Error: nu::shell::type_mismatch
    
      × Type mismatch.
       ╭─[entry #1:1:24]
     1 │ date now | format date %Ey
       ·                        ─┬─
       ·                         ╰── invalid format
  5. Pantakit-Joseph commented on Mar 7, 2025

    @Pantakit-Joseph
    Author

    The command date now | format date '%x %X' doeswork as it should now with$env.LC_TIME=en_US.UTF-8`, and outputs the default date and time of "03/08/2025 02:39:28 AM" correctly.

    But a "Type mismatch" error came along when the value of $env.LC_TIME changed to "th_TH.UTF-8", like this:

    ~> $env.LC_TIME = "en_US.UTF-8"
    ~> date now | format date '%x %X'
    03/08/2025 02:39:28 AM
    ~> $env.LC_TIME = "th_TH.UTF-8"
    Error: nu::shell::type_mismatch
    
      × Type mismatch.
        ╭─[default_env.nu:25:33]
     24 │         (ansi magenta)
     25 │         (date now | format date '%x %X') # try to respect user's locale
        ·                                 ───┬───
        ·                                    ╰── invalid format
     26 │     ] | str join | str replace --regex --all "([/:])" $"(ansi green)${1}(ansi magenta)" |
        ╰────
    
    ~> date now | format date '%x %X'
    Error: nu::shell::type_mismatch
    
      × Type mismatch.
       ╭─[entry #4:1:24]
     1 │ date now | format date '%x %X'
       ·                        ───┬───
       ·                           ╰── invalid format
       ╰────
    
    
  6. fdncred commented on Mar 7, 2025

    @fdncred
    Contributor

    This seems to affect any locale that uses the %E modifier, which is unimplemented by chrono:

    No clue how to handle the %E modifier.

  7. added
    help wantedstatus: Extra attention is needed
    A:datetime-handlingSemantics and implementation of the datetime/duration types and commands
    and removed
    status:needs-triageAn issue that hasn't had any proper look
    on Mar 7, 2025
  8. foxmean commented on Aug 1, 2025

    @foxmean

    I can reproduced this bug on NixOS 25.05 machine but not on macOS macOS Sequoia version 15.6 even if I set $env.LC_TIME = "th_TH.UTF-8" . This is maybe only bug on GNU/Linux system somehow?

  9. added this to the v0.116.0 milestone on Aug 27, 2026
  10. added a commit that references this issue on Aug 27, 2026
    a854062
  11. added a commit that references this issue on Aug 28, 2026
    d6a9f6b
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

    A:datetime-handlingSemantics and implementation of the datetime/duration types and commandscategory:upstreamproblem with upstream dependencyhelp wantedstatus: Extra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions