gpt4 book ai didi

nix-shell 无法更改语言环境警告

转载 作者:行者123 更新时间:2023-12-05 05:02:11 24 4
gpt4 key购买 nike

在没有 shell.nix 文件的情况下运行 nix-shell 时,弹出以下警告:

$ nix-shell -p glibcLocales
bash: warning: setlocale: LC_TIME: cannot change locale (en_GB.UTF-8): No such file or directory

[nix-shell:~]$

如果找到几篇关于将环境变量 LOCALE_ARCHIVE_2_27 设置为某个路径的帖子。如何将这样的环境变量自动设置为正确的路径?使用一些 shell.nix 文件会有帮助吗?

编辑:我的语言环境设置如下:

$ cat /etc/locale.conf
LANG="en_US.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_TIME="en_GB.UTF-8"

如果我从 /etc/locale.conf 中删除 LC_TIME="en_GB.UTF-8",则警告不会出现,即使 使用 LC_TIME="en_GB.UTF-8"nix-shell -p glibcLocales

在 Fedora 32 上使用 nix-2.3.6

$ nix-channel --list
nixpkgs https://nixos.org/channels/nixpkgs-unstable

最佳答案

您可以在 shell.nix 中使用有效路径填充 $LOCALE_ARCHIVE_2_27,如下所示:

❯ cat shell.nix
with import <nixpkgs> {};
mkShell {
LOCALE_ARCHIVE_2_27 = "${glibcLocales}/lib/locale/locale-archive";
buildInputs = [
hello
];
}
❯ nix-shell

[nix-shell:~]$ echo $LOCALE_ARCHIVE_2_27
/nix/store/r24xc904amrdwfrzyijxmylxnxmwacm9-glibc-locales-2.31/lib/locale/locale-archive

或者将表达式作为参数传递

❯ nix-shell -E 'with import <nixpkgs> { }; runCommand "dummy" { LOCALE_ARCHIVE_2_27 = "${glibcLocales}/lib/locale/locale-archive"; buildInputs = [ hello ]; } ""'

[nix-shell:~]$ echo $LOCALE_ARCHIVE_2_27
/nix/store/r24xc904amrdwfrzyijxmylxnxmwacm9-glibc-locales-2.31/lib/locale/locale-archive

此处有更多详细信息 https://gist.github.com/peti/2c818d6cb49b0b0f2fd7c300f8386bc3

关于nix-shell 无法更改语言环境警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62287269/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com