While trying to fix #50902, I discovered that trying to build python37Packages.docutils fails in the test step on Darwin with the following error:
```running install tests
Traceback (most recent call last):
File "test3/alltests.py", line 80, in
suite = suite()
File "test3/alltests.py", line 69, in suite
'test_', packages=1)
File "/private/var/folders/3m/9syglhc96qg7ydzvx9fl3rwc00n97t/T/nix-build-python3.7-docutils-0.14.drv-0/docutils-0.14/test3/package_unittest.py", line 101, in loadTestModules
module = import_module(mod)
File "/private/var/folders/3m/9syglhc96qg7ydzvx9fl3rwc00n97t/T/nix-build-python3.7-docutils-0.14.drv-0/docutils-0.14/test3/package_unittest.py", line 132, in import_module
mod = __import__(name)
File "/private/var/folders/3m/9syglhc96qg7ydzvx9fl3rwc00n97t/T/nix-build-python3.7-docutils-0.14.drv-0/docutils-0.14/test3/test_command_line.py", line 19, in
locale_encoding = locale.getlocale()[1] or locale.getdefaultlocale()[1]
File "/nix/store/yzdxaqyjpiygbaxb91nb723ghxa7f8fz-python3-3.7.1/lib/python3.7/locale.py", line 587, in getlocale
return _parse_localename(localename)
File "/nix/store/yzdxaqyjpiygbaxb91nb723ghxa7f8fz-python3-3.7.1/lib/python3.7/locale.py", line 495, in _parse_localename
raise ValueError('unknown locale: %s' % localename)
ValueError: unknown locale: UTF-8
[Full build.log](https://github.com/NixOS/nixpkgs/files/2618549/build.log)
Seems to have been bumped into before: https://logs.nix.samueldr.com/nixos/2018-08-02#1439819;
It appears to be related to this very old Python bug: https://bugs.python.org/issue18378
### Steps to reproduce
```nix-build -E 'let nixpkgs = import (builtins.fetchTarball { url = "https://github.com/endgame/nixpkgs/archive/bc565bba2762edf12a40fb0c153d676e66e28faa.tar.gz"; sha256 = "1hdcg4b84c0mw959d6x9pxal95j58ks82fpfsy5sbazs6s40hdhy"; }) {}; in nixpkgs.python37Packages.docutils'
nix-info -m:
- system: `"x86_64-darwin"`
- host os: `Darwin 17.7.0, macOS 10.13.6`
- multi-user?: `no`
- sandbox: `no`
- version: `nix-env (Nix) 2.1.3`
- channels(che347): `"nixpkgs-19.03pre159614.f52b7f5c345, nixpkgs-18.09-darwin-18.09pre152973.012b9e6c219"`
- nixpkgs: `/Users/che347/.nix-defexpr/channels/nixpkgs`
https://stackoverflow.com/a/19961403/429232 says the standard solution is to set the locale env vars sensibly, but that's not going to make it into the nix build environment.
You should perhaps open a PR with c3ab224 ?
We've been seeing similar a lot. The fix should be the same as https://github.com/NixOS/nixpkgs/pull/51051.
The fix for this is already in staging (#50886)
@veprbl Good to know. Does this issue need to remain open, then?
Most helpful comment
https://stackoverflow.com/a/19961403/429232 says the standard solution is to set the locale env vars sensibly, but that's not going to make it into the nix build environment.