common: drop locale setting hack #36524

pull fanquake wants to merge 3 commits into bitcoin:master from fanquake:drop_locale_hacks changing 3 files +11 −12
  1. fanquake commented at 7:31 AM on October 14, 2026: member

    This was added to work around boost::filesystem throwing when the environments locale was invalid. Boost.Filesystem has been removed, and std::filesystem doesn't use the locale on POSIX (and bitcoind never calls setlocale).

    Qt calls setlocale(LC_ALL, "") on startup, and falls back to C.UTF-8 if the locale isn't UTF-8.

    Alternative to #36399, which extends the hack further.

  2. DrahtBot commented at 7:31 AM on October 14, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--006a51241073e994b41acfe9ec718e94-->

    External sites

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK maflcko, stickies-v, sedited

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  3. fanquake force-pushed on Oct 14, 2026
  4. DrahtBot added the label CI failed on Oct 14, 2026
  5. maflcko commented at 7:42 AM on October 14, 2026: member

    Qt calls setlocale(LC_ALL, "") on startup, and falls back to C.UTF-8 if the locale isn't UTF-8.

    Can you add a reference/source to this claim?

  6. maflcko commented at 8:20 AM on October 14, 2026: member

    lgtm ACK 622df9e941dd55fc9b01125ea1de659ed6a9794e

  7. sedited approved
  8. sedited commented at 8:56 AM on October 14, 2026: contributor

    ACK 622df9e941dd55fc9b01125ea1de659ed6a9794e

  9. DrahtBot removed the label CI failed on Oct 14, 2026
  10. hebasto commented at 2:16 PM on October 14, 2026: member

    Doesn’t this change affect the behaviour of the scripts specified via the -*notify options in environments where the locale is invalid?

  11. maflcko commented at 2:24 PM on October 14, 2026: member

    Yes, that is also what Ralph says (https://git.fish.foo/bitcoin/bitcoin/pulls/36524#author-ralph) , but I think users are better off not setting an invalid locale. If they really want to set an invalid locale, they are better off setting the locale in their notify script explicitly. (Explicitly setting it works before and after the changes here)

  12. in src/common/system.cpp:76 in 622df9e941 outdated
      69 | -    // may be invalid, in which case the "C.UTF-8" locale is used as fallback.
      70 | -#if !defined(WIN32) && !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__OpenBSD__) && !defined(__NetBSD__)
      71 | -    try {
      72 | -        std::locale(""); // Raises a runtime error if current locale is invalid
      73 | -    } catch (const std::runtime_error&) {
      74 | -        setenv("LC_ALL", "C.UTF-8", 1);
    


    stickies-v commented at 3:46 PM on October 14, 2026:

    This surfaces a bug in interface_gui.py, that passes on master but fails on 622df9e941dd55fc9b01125ea1de659ed6a9794e.

    On CI, we set LC_ALL=C.UTF-8 in all scripts, so the locale is set in all tests, which means that we're not really testing this change.

    When running this test locally on a Linux environment with LC_ALL unset and no nl_NL.UTF-8 locale installed, the interface_gui.py test fails. This is because in test_node.py:302, we set subp_env.setdefault("LC_ALL", "nl_NL.UTF-8"). On CI, this operation is a no-op because LC_ALL is always set, so the nl_NL.UTF-8 locale is never actually set. When it is actually set, and nl_NL.UTF-8 isn't installed on the machine, the test fails.

    Tested in a debian:trixie container:

    $ python3 build/test/functional/interface_gui.py
    
    ...
      2026-10-14T14:57:03.224515Z TestFramework (INFO): PRNG seed is: 6521282163018713296
      2026-10-14T14:57:03.276866Z TestFramework (INFO): Initializing test directory /tmp/bitcoin_func_test_nr9vej0d
      2026-10-14T14:57:03.871440Z TestFramework (INFO): Test that bitcoin-gui starts up and can be stopped via RPC
      2026-10-14T14:57:04.243870Z TestFramework (ERROR): Unexpected exception:
      Traceback (most recent call last):
        File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_framework.py", line 146, in main
          self.run_test()
          ~~~~~~~~~~~~~^^
        File "/Users/stickies-v/code/bitcoin/review/36524/build/test/functional/interface_gui.py", line 34, in run_test
          self.stop_node(0)
          ~~~~~~~~~~~~~~^^^
        File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_framework.py", line 527, in stop_node
          self.nodes[i].stop_node(expected_stderr, wait=wait)
          ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_node.py", line 517, in stop_node
          self.wait_until_stopped(expected_stderr=expected_stderr)
          ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_node.py", line 563, in wait_until_stopped
          self.wait_until(lambda: self.is_node_stopped(**kwargs), timeout=timeout)
          ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_node.py", line 913, in wait_until
          return wait_until_helper_internal(test_function, timeout=timeout, timeout_factor=self.timeout_factor, check_interval=check_interval)
        File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/util.py", line 449, in wait_until_helper_internal
          if predicate():
             ~~~~~~~~~^
        File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_node.py", line 563, in <lambda>
          self.wait_until(lambda: self.is_node_stopped(**kwargs), timeout=timeout)
                                  ~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
        File "/Users/stickies-v/code/bitcoin/review/36524/test/functional/test_framework/test_node.py", line 548, in is_node_stopped
          raise AssertionError("Unexpected stderr {} != {}".format(stderr, expected_stderr))
      AssertionError: Unexpected stderr Detected locale "C" with character encoding "ANSI_X3.4-1968", which is not UTF-8.
      Qt depends on a UTF-8 locale, and has switched to "C.UTF-8" instead.
      If this causes problems, reconfigure your locale. See the locale(1) manual
      for more information.
    

    The test runs fine with LC_ALL=C.UTF-8 python3 build/test/functional/interface_gui.py.

    From #35551, it seems like we set a well-translated language to ensure that in a foreign locale, RPC strings still come through in English. If that's what we want to achieve, then perhaps we could e.g. add https://github.com/stickies-v/bitcoin/commit/a39fa5420ed965f8975221ce49bd813fac3aed61 as a minimal fix prior to this change?


    fanquake commented at 2:38 AM on October 15, 2026:

    I'm not completely sure what the expectations are with this test, but I've cherry-picked your commit here.


    stickies-v commented at 9:40 AM on October 15, 2026:

    From #35551 (review):

    Could also set something like LC_ALL=nl_NL.UTF-8 to check the RPC response is not translated by accident?

  13. stickies-v commented at 3:47 PM on October 14, 2026: contributor

    Concept ACK

    This surfaces an already buggy test, that now fails on some local environments, see comment.

  14. fanquake force-pushed on Oct 15, 2026
  15. maflcko commented at 6:30 AM on October 15, 2026: member

    Only change is a gui test fixup.

    review ACK 27be7413e82072e8e68b958e808bbee379f4ac15 πŸš‡

    <details><summary>Show signature</summary>

    Signature:

    untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
    RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
    trusted comment: review ACK 27be7413e82072e8e68b958e808bbee379f4ac15 πŸš‡
    zmTJxrqt5CAm6rIQ+TMaGY6wW+CucsSb5e19C8wSwr0yqL18TX53qz6OFVwumCGNyfHrBbGmMx16i1yiR0xADw==
    

    </details>

  16. DrahtBot requested review from stickies-v on Oct 15, 2026
  17. DrahtBot requested review from sedited on Oct 15, 2026
  18. maflcko commented at 6:45 AM on October 15, 2026: member

    I mean if people feel strongly, there could be a release note along the lines:

    The UTF-8 fallback for invalid or unavailable environment locales has been removed. Affected -*notify scripts may explicitly set a valid locale, such as LC_ALL=C.UTF-8, if needed.

  19. stickies-v commented at 9:43 AM on October 15, 2026: contributor

    ACK 27be7413e82072e8e68b958e808bbee379f4ac15

    I mean if people feel strongly, there could be a release note along the lines:

    I actually think that would be good. Shouldn't affect many people, but probably some, and having a mention in the release notes may save them a lot of confusion. Your proposed text works well for me.

  20. test: run GUI nodes in Dutch with -lang
    This changes test behavior: GUI nodes now run with the Dutch
    translation on all systems, also in CI. Before, they ran in English in
    CI, because CI exports LC_ALL=C.UTF-8 and setdefault("LC_ALL",
    "nl_NL.UTF-8") did nothing. So the translation check never ran there.
    
    The old setting also fails when LC_ALL is not set and nl_NL.UTF-8 is
    not installed: Qt prints a warning to stderr, and interface_gui.py fails
    when SetupEnvironment() no longer replaces LC_ALL. -lang does not need
    the locale to be installed. Date and number formats do not change.
    1164c77d2d
  21. common: drop locale setting hack
    This was added to work around `boost::filesystem` throwing when the
    environments locale was invalid. Boost.Filesystem has been removed, and
    `std::filesystem` doesn't use the locale on POSIX (and bitcoind never
    calls `setlocale`).
    
    Qt calls `setlocale(LC_ALL, "")` on startup, and falls back to C.UTF-8
    if the locale isn't UTF-8.
    cbd2964db7
  22. doc: add release note for #36524 43bb5e3c46
  23. fanquake force-pushed on Oct 16, 2026
  24. fanquake commented at 1:05 AM on October 16, 2026: member

    Added a release note.

  25. DrahtBot added the label CI failed on Oct 16, 2026
  26. DrahtBot removed the label CI failed on Oct 16, 2026
  27. maflcko commented at 7:51 AM on October 16, 2026: member

    review ACK 43bb5e3c467f38566f7d7271b0030ef4af1cf78c πŸš‚

    <details><summary>Show signature</summary>

    Signature:

    untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
    RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
    trusted comment: review ACK 43bb5e3c467f38566f7d7271b0030ef4af1cf78c πŸš‚
    0RN8toZudX3WfXDZvsUbFkOd9P5Kd1le5Ef2zAGNlR9jHQMC0uLLAW10sHCvqSo5XvCP6+k/ZD/wjaINsvKADA==
    

    </details>

  28. stickies-v commented at 7:58 AM on October 16, 2026: contributor

    ACK 43bb5e3c467f38566f7d7271b0030ef4af1cf78c

  29. sedited approved
  30. sedited commented at 7:53 AM on October 19, 2026: contributor

    ACK 43bb5e3c467f38566f7d7271b0030ef4af1cf78c

  31. sedited merged this on Oct 19, 2026
  32. sedited closed this on Oct 19, 2026

  33. fanquake deleted the branch on Oct 19, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-10-24 09:51 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me