Skip to content

Can't properly set LOCALE_ARCHIVE #378

Description

@mole99

Describe the bug

On my system, I have de_AT.UTF-8 set as my locale. Whenever I start a devshell, I get the following warnings:

bash: warning: setlocale: LC_CTYPE: cannot change locale (de_AT.UTF-8): No such file or directory
bash: warning: setlocale: LC_CTYPE: cannot change locale (de_AT.UTF-8): No such file or directory
bash: warning: setlocale: LC_COLLATE: cannot change locale (de_AT.UTF-8): No such file or directory
bash: warning: setlocale: LC_CTYPE: cannot change locale (de_AT.UTF-8): No such file or directory
bash: warning: setlocale: LC_CTYPE: cannot change locale (de_AT.UTF-8): No such file or directory
bash: warning: setlocale: LC_COLLATE: cannot change locale (de_AT.UTF-8): No such file or directory

To get rid of these warnings, I need to set LOCALE_ARCHIVE to "${pkgs.glibcLocales}/lib/locale/locale-archive".
This works just fine in pkgs.mkShell using:

LOCALE_ARCHIVE = lib.optionalString pkgs.stdenv.isLinux "${pkgs.glibcLocales}/lib/locale/locale-archive";

Unfortunately, when trying to do the same in devshell.mkShell using env:

  env = [
    {
      name = "NIX_PYTHONPATH";
      value = "${librelane-env-sitepackages}";
    }
  ]
  ++ lib.optionals stdenv.hostPlatform.isLinux [{
    name = "LOCALE_ARCHIVE";
    value = "${glibcLocales}/lib/locale/locale-archive";
  }]

I still get these warnings, even though LOCALE_ARCHIVE has been set correctly:

$ echo $LOCALE_ARCHIVE
/nix/store/hjlkypp9lpxwzsjycpy7nqg2mnl7qhzv-glibc-locales-2.40-66/lib/locale/locale-archive

The reason is that LOCALE_ARCHIVE is set too late, after which the warnings have already been printed.
When I export LOCALE_ARCHIVE to the correct path before invoking the devshell, the warnings are resolved.

To Reproduce

Steps to reproduce the behavior:

Set your locale to de_AT.UTF-8.

Expected behavior

No warnings should be printed.

System information

Linux

  • system: "x86_64-linux"
  • host os: Linux 6.12.95+deb13-amd64, Debian GNU/Linux, 13 (trixie), nobuild
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.31.0
  • nixpkgs: /nix/store/w0d0sydj6sbcyp1l36ya9wbjh0j56c3j-source

Additional context

None

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions