8000 Changing LOCPATH environment variable does not reinitialize locale subsystem · Issue #5815 · fish-shell/fish-shell · GitHub
[go: up one dir, main page]

Skip to content

Changing LOCPATH environment variable does not reinitialize locale subsystem #5815

@therealpxc

Description

@therealpxc

Fish has apparently got some monitoring built in to detect locale changes and change encodings accordingly, which is awesome.

But I noticed when working around a locale configuration issue (once mistakenly reported as a Fish bug here: #4935) that LOCALE_ARCHIVE is not among them.

This means that unfortunately, setting LOCALE_ARCHIVE inside one's Fish configuration is insufficient to get certain prompt characters to print correctly, even though subsequent launches of Fish (in whose environment LOCALE_ARCHIVE is already set) will have the locale set correctly.

To reproduce, simply (1) have Fish launch with a glibc seeking a locale-archive file in one directory, which lacks some locales, and change the LOCALE_ARCHIVE environment variable to one that includes more locales. Then to witness the other problem, (2) change one of the monitored locale environment variables so that Fish attempts to reinitialize locale stuff.

Here's a demonstration

Last login: Fri Apr 12 20:51:53 2019 from 10.144.8.187
pxc@somehost:~ $ fish -l -i
Welcome to fish, the friendly interactive shell
 somehost ? ~ ? echo $LOCALE_ARCHIVE
/nix/store/67b3n3zga54zic8s72vd4sdz1nl4lr0q-glibc-locales-2.27/lib/locale/locale-archive
 somehost ? ~ ? set -e LOCALE_ARCHIVE
 somehost ? ~ ? fish --debug-level 5 ^| grep setlocale
<5> fish: init_locale() setlocale(): '(null)'
Welcome to fish, the friendly interactive shell
 somehost ? ~ ? set -gx LANG en_US.UTF-8
<5> fish: init_locale() setlocale(): '(null)'
 somehost ? ~ ? exit
 somehost ? ~ ? cat ~/.config/fish/conf.d/00000-nixify.fish
if not set -q NIX_PROFILE
  if not functions -q fenv
    set fenvdir ~/.local/share/omf/pkg/foreign-env/functions
    test -d "$fenvdir"; and set fish_function_path $fish_function_path $fenvdir
  end
  fenv source /etc/profile.d/nix.sh ^/dev/null
end

# for non-NixOS, see https://github.com/NixOS/nixpkgs/issues/54418
set -q LOCALE_ARCHIVE
or set -gx LOCALE_ARCHIVE (nix-build --no-out-link '<nixpkgs>' -A glibcLocales)'/lib/locale/locale-archive'
 somehost ? ~ ? source ~/.config/fish/conf.d/00000-nixify.fish
 somehost ? ~ ? echo $LOCALE_ARCHIVE
/nix/store/67b3n3zga54zic8s72vd4sdz1nl4lr0q-glibc-locales-2.27/lib/locale/locale-archive
 somehost ? ~ ? fish --debug-level 5 ^| grep setlocale
<5> fish: init_locale() setlocale(): 'en_US.UTF-8'
Welcome to fish, the friendly interactive shell
 somehost  ~  set -gx LANG en_AU.UTF-8
<5> fish: init_locale() setlocale(): 'en_AU.UTF-8'
 somehost  ~  set -gx LANG en_US.UTF-8
<5> fish: init_locale() setlocale(): 'en_US.UTF-8'
 somehost  ~  exit
 somehost ? ~ ?

Given that Fish's setlocale() occur 740A s but fails when LANG is reset after setting LOCALE_ARCHIVE, I worry that some limitation of glibc may be involved, but I don't really know how that works. I hope that's not the case, and that this bug report can still be useful. 😳

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0