NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.12k stars 14.16k forks source link

Fish shell displays ? instead of Powerline symbols #54418

Open hajdamak opened 5 years ago

hajdamak commented 5 years ago

Issue description

Fish themes that use Powerlines symbols (like Bob the fish) displays ? instead of proper Powerline symbols.

Steps to reproduce

Technical details

wedens commented 5 years ago

Which font do you use? Does it have powerline glyphs?

hajdamak commented 5 years ago

Yes it has. Hack NerdFont Mono: https://github.com/ryanoasis/nerd-fonts/blob/master/patched-fonts/Hack/Regular/complete/Hack%20Regular%20Nerd%20Font%20Complete%20Mono.ttf

I have tested it in Alacritty and Gnome Terminal.

On the same setup Fish displays symbols correctly when executed directly from Ubuntu, Junest or from Linuxbrew.

lilyball commented 5 years ago

Could this be a locale issue?

hajdamak commented 5 years ago

Highly likely. I had similar issue in Junest: https://github.com/fsquillace/junest/issues/217 . However it was simply fixed by changing locale settings. In nix such simple fix does not seem to work.

therealpxc commented 5 years ago

This issue looks a lot like https://github.com/NixOS/nixpkgs/issues/38991, but the workaround, setting LOCALE_ARCHIVE differently, doesn't seem to work.

New versions of fish don't print any information about what the locale gets set to in their debug output, but older ones do. On my affected systems, Fish from nixpkgs 18.03 (2.7.1) prints this output at --debug-level 2:

$ fish --debug-level 2
<2> fish: exec_path: '/nix/store/1648ydgjfh5dm6j14wxl08s04ksfn8f3-fish-2.7.1/bin/fish'
<2> fish: determine_config_directory_paths() results:
paths.data: /nix/store/1648ydgjfh5dm6j14wxl08s04ksfn8f3-fish-2.7.1/share/fish
paths.sysconf: /nix/store/1648ydgjfh5dm6j14wxl08s04ksfn8f3-fish-2.7.1/etc/fish
paths.doc: /nix/store/1648ydgjfh5dm6j14wxl08s04ksfn8f3-fish-2.7.1/share/doc/fish
paths.bin: /nix/store/1648ydgjfh5dm6j14wxl08s04ksfn8f3-fish-2.7.1/bin
<2> fish: locale var LANG='en_US.UTF-8'
<2> fish: locale var LANGUAGE=''
<2> fish: locale var LC_ALL=''
<2> fish: locale var LC_ADDRESS=''
<2> fish: locale var LC_COLLATE=''
<2> fish: locale var LC_CTYPE=''
<2> fish: locale var LC_IDENTIFICATION=''
<2> fish: locale var LC_MEASUREMENT=''
<2> fish: locale var LC_MESSAGES=''
<2> fish: locale var LC_MONETARY=''
<2> fish: locale var LC_NAME=''
<2> fish: locale var LC_NUMERIC=''
<2> fish: locale var LC_PAPER=''
<2> fish: locale var LC_TELEPHONE=''
<2> fish: locale var LC_TIME=''
<2> fish: init_locale() setlocale(): '(null)'

So I guess there's a problem with the locale information fish is getting from glibc, but it's not the archive version incompatibility crap, because the glibc versions on my NixOS system (which doesn't exhibit this issue) and on my Ubuntu system (which does) are the same. :-\

therealpxc commented 5 years ago

Oops, I'm a goof. It is glibc failing to find the locale archives, although I'm not exactly sure where it's going wrong. And current versions of fish do tell you about what locale info they're getting from glibc, but at --debug-level 5:

? ~ ? fish --debug-level 5 -c exit ^| grep setlocale
<5> fish: init_locale() setlocale(): '(null)'

This means there are at least three workarounds:

Workaround 1: Set LOCALE_ARCHIVE to point to the non-NixOS host distro's locale-archive file

Note that this will only work if the locale-archive on the distro is in a format compatible with Nixpkgs' glibc; compatibility may break between versions of glibc.

? ~ ? env LOCALE_ARCHIVE=/usr/lib/locale/locale-archive fish --debug-level 5 -c exit ^| grep setlocale
<5> fish: init_locale() setlocale(): 'en_US.UTF-8'

Workaround 2: Set LOCALE_ARCHIVE to the complete locale-archive file from Nixpkgs

This will always work, but it's a >100MB download.

? ~ ? env "LOCALE_ARCHIVE="(nix-build --no-out-link '<nixpkgs>' -A glibcLocales)"/lib/locale/locale-archive" fish --debug-level 5 -c exit ^| grep setlocale
<5> fish: init_locale() setlocale(): 'en_US.UTF-8'

Workaround 3: Set LANG to C

This will always work, but you can't actually use the locale you want.

? ~ ? env LANG=C.UTF-8 fish --debug-level 5 -c exit ^| grep setlocale
<5> fish: init_locale() setlocale(): 'C.UTF-8'
hajdamak commented 5 years ago

@therealpxc Thank's a lot for your solutions. Workaround 2 solved the problem on my side.

stale[bot] commented 4 years ago

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.