Skip to content

Null pointer when running code2prompt from CLI with LC_ALL unset #155

@superandoni

Description

@superandoni

Installed code2prompt 3.0.2 via homebrew on MacOS X Sequoia 15.4.1 on a M1 Macbook Pro.

My output of locale:

LANG="en_UK.UTF-8"
LC_COLLATE="C"
LC_CTYPE="C"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=

Running code2prompt in any folder gives the following error:

▹▹▹▹▸ Done!
thread 'main' panicked at crates/code2prompt/src/main.rs:182:89:
called `Result::unwrap()` on an `Err` value: Error { kind: SystemInvalidReturn { function_name: "newlocale", message: "newlocale unexpectedly returned a null pointer." } }
stack backtrace:
   0:        0x102db5d58 - <std::sys::backtrace::BacktraceLock::print::DisplayBacktrace as core::fmt::Display>::fmt::he95167bc0db69172
   1:        0x102c2920c - core::fmt::write::h7a9b1a2c5a4d720d
   2:        0x102d9d068 - std::io::Write::write_fmt::h6ba1180d709be9ef
   3:        0x102db5c18 - std::sys::backtrace::BacktraceLock::print::he986caf53af0c7c0
   4:        0x102dbb17c - std::panicking::default_hook::{{closure}}::h91abe66414d5ff97
   5:        0x102dbb08c - std::panicking::default_hook::hd88a7d3ab5420733
   6:        0x102dbb700 - std::panicking::rust_panic_with_hook::h0c4570804070c568
   7:        0x102db615c - std::panicking::begin_panic_handler::{{closure}}::h137406384c01ca5e
   8:        0x102db5fa0 - std::sys::backtrace::__rust_end_short_backtrace::hbbf6c8bb05b960c8
   9:        0x102dbb218 - _rust_begin_unwind
  10:        0x102e4659c - core::panicking::panic_fmt::h8df0ae8acbd1e44d
  11:        0x102e464ec - core::result::unwrap_failed::h724a6477a0a39f8d
  12:        0x102c0933c - code2prompt::main::h5a9036ecf9c28fb2
[2]    28425 abort      RUST_BACKTRACE=full code2prompt .

Workaround found by explicitly setting LC_ALL:
LC_ALL="C" code2prompt .

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions