Nix-shell on debian13 - problem with locale

  • I use nix (Nix) 2.25.3 on debian 13. Yet with more or less basic to 0 experience.
  • nix was installed via a nix_install.sh.

What I ran quite regularly (and more or less successfully) is telegram-desktop inside a nix-shell. This stopped working since (my guess) the last apt-upgrade I ran yesterday.

apparently nix-shell has a problem with the locale inside the shell.

✦ ❯ nix-shell -p telegram-desktop run telegram-desktop
bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8): No such file or directory

~ via ❄️  impure (shell) 
❯ locale -a | grep en_US
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory

~ via ❄️  impure (shell) 
❯ 
exit

~ took 41s 
✦ ❯ locale -a | grep en_US
en_US
en_US.iso885915
en_US.utf8

this seems to be a general nix-shell issue, as it happens with other packages, i.e. nano, alike.

✦ ❯ nix-shell -p nano
this path will be fetched (0.50 MiB download, 2.50 MiB unpacked):
  /nix/store/028y5rvlnq6vzpvbvvbx85nzd70nvl69-nano-8.2
copying path '/nix/store/028y5rvlnq6vzpvbvvbx85nzd70nvl69-nano-8.2' from 'https://cache.nixos.org'...
bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8): No such file or directory

how would you suggest to approach this issue?

  1. it would definitely have helped whether I did not pick a faulty command from my history, but the correct one nix-shell -p telegram-desktop --run telegram-desktop (--run ..., not just run ...).

Then I wouldn’t have noticed that issue with the locale because it ran ‘good enough’ though.

❯ nix-shell -p telegram-desktop
bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8): No such file or directory

~ via ❄️  impure (shell) 
❯ locale -a | grep -i en_US
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory

~ via ❄️  impure (shell) 
❯ locale -a | grep -i utf  
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C.utf8

this is not an urgent issue for me as I do not care about telegram not running as it should (with UTF-8). For sake of completeness and academic research I leave it in here though.

I noticed this with one of my trixie systems after upgrading to Debian 13 last week. I have Nix 2.31.1, originally installed using the nix.dev install script.

It appears that running locale-gen did the trick for me.

If that doesn’t work, try editing /etc/locale.conf and change en_US.UTF-8 to en_US.utf-8and run locale-gen again, before reverting the change and running locale-gen one last time for good measure.

thx, that did nothing at all for me though

What about the next part I mentioned after that?

sorry, I meant the entire cycle you mentioned, just a lazy quote.

That said, I have quite a mixed locale.conf

LANG=en_US.UTF-8
LC_ADDRESS=de_DE.UTF-8
LC_IDENTIFICATION=de_DE.UTF-8
LC_MEASUREMENT=de_DE.UTF-8
LC_MONETARY=de_DE.UTF-8
LC_NAME=de_DE.UTF-8
LC_NUMERIC=de_DE.UTF-8
LC_PAPER=de_DE.UTF-8
LC_TELEPHONE=de_DE.UTF-8
LC_TIME=de_DE.UTF-8

however changing all that to en_US throughout neither makes any difference in the mentioned behavior.

And how about the case sensitivity with UTF-8 vs utf-8 as I indicated in my first reply? Ignore my very last step until you’ve tested each step.

here is, what I did

# try nix-shell
> nix-shell -p nano

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

# modify /etc/locale.conf
> sudo sed -i 's/UTF-8/utf-8/' /etc/locale.conf

# run locale-gen
> sudo locale-gen
Generating locales (this might take a while)...
  de_DE.UTF-8... done
  en_US.UTF-8... done
Generation complete.

# try nix-shell again
> nix-shell -p nano

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

❯ nix --version
nix (Nix) 2.25.3