New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fish: Could not set up terminal #36146

Open
bbc2 opened this Issue Feb 28, 2018 · 8 comments

Comments

Projects
None yet
4 participants
@bbc2
Copy link

bbc2 commented Feb 28, 2018

Issue description

After logging into my host via SSH, I get the following output despite rxvt_unicode.terminfo being installed system-wide:

<W> fish: Could not set up terminal.
<W> fish: TERM environment variable set to 'rxvt-unicode-256color'.
<W> fish: Check that this terminal type is supported on this system.
<W> fish: Using fallback terminal type 'ansi'.
Welcome to fish, the friendly interactive shell

Subsequent invocations of fish (fish, sudo -s) are not affected unless rxvt_unicode.terminfo is removed (in which case the warning appears twice instead of once on initial SSH login).

Steps to reproduce

Use the following configuration:

users.extraUsers.<username> = {
  shell = pkgs.fish;
  [...]
};
environment.systemPackages = with pkgs; [
  rxvt_unicode.terminfo
];
programs.fish.enable = true;

Then, connect to the machine using SSH from urxvt (rxvt-unicode) or termite.

Technical details

  • system: "x86_64-linux"
  • host os: Linux 4.9.84, NixOS, 17.09.3094.211309626af (Hummingbird)
  • multi-user?: yes
  • sandbox: no
  • version: nix-env (Nix) 1.11.16
  • channels(root): "nixos-17.09.3094.211309626af"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
@bbc2

This comment has been minimized.

Copy link
Author

bbc2 commented Feb 28, 2018

I tried grabbing fish and fish-foreign-env from unstable-18.03pre129076.831ef4756e3 but that didn't help.

@rembo10

This comment has been minimized.

Copy link
Contributor

rembo10 commented Sep 14, 2018

I'm getting the same thing, same setup, on nixos-unstable. Maybe @layus can help?

@layus

This comment has been minimized.

Copy link
Contributor

layus commented Sep 14, 2018

As far as I understand this issue, it appears because fish initializes the terminal first, then loads init scripts with TERMINFO* env vars before initializing the terminal. Note that this warning is inconsequential, and that your terminal is fully functional. Otherwise you would see the warning twice, and your terminal would be partially broken.

As before, you can fix this issue by symlinking ~/.terminfo to .nix-profile/share/terminfo if rxvt_unicode.terminfo is installed for your user, and to /etc/terminfo if it is installed globally.

It so appears that /etc/terminfo is not in the default lookup path of termcap... I should investigate that, or maybe just read my previous comments about that in #19785.

@layus

This comment has been minimized.

Copy link
Contributor

layus commented Sep 14, 2018

Oh, I remember now. By default, it looks in "${ncurses}/share/terminfo".
/etc/terminfo is useless on NixOS. Just there for easy inspection and misleading users ;-).

@rembo10

This comment has been minimized.

Copy link
Contributor

rembo10 commented Sep 14, 2018

Cool, thanks for the help! I realized just after I posted that it was being reinitialized with the correct TERMINFO_DIRS. And if I ssh'd in tmux, it would work (tmux sets the $TERM=screen), so I knew it was reading something, I just wasn't sure what.

But if I ssh'd into a Ubuntu box, I don't get the warnings - so maybe it's something we can fix in nixos? I can have a look.

@layus

This comment has been minimized.

Copy link
Contributor

layus commented Sep 14, 2018

Setting TERMINFO_DIRS, that's the way we use to fix it. But fish being very interactive by nature, it initializes the terminal before reading event the most elementary config files. Usually, the shell is responsible for initializing the env vars, so we have a chicken and egg problem here. We need fish to parse and export TERMINFO_DIRS, but fish needs TERMINFO_DIRS to be configured before starting. All the shells handle this by delaying term setup until env vars are read. Fish did it for some time then this problem appeared. Bisection could find the culprit.

If we cannot / do not want to fix this upstream in fish, we can also

  1. add rxvt_unicode to ncurses. It must be the only term emulator that is not in upstream ncurses database. there is no reason to keep it lonely and isolated like that ;-)
  2. We could wrap/patch fish in nixos to first parse the environment. The following would be enough. But do we want to wrap every fish invocation in sh ?
#!/nix/store/...-sh/bin/sh
exec /nix/store/...-fish/bin/fish "$@"
@layus

This comment has been minimized.

Copy link
Contributor

layus commented Sep 14, 2018

Well, no, that is not enough. We need to detect if this is a login shell... But nonetheless, I do not think we want to wrap fish in another shell. Patchin could be a way to go. The current statu-quo is already the result from a patch I upstreamed to fish.

As for 1., I guess this tells it all: https://lists.gnu.org/archive/html/bug-ncurses/2009-10/msg00032.html

@wtdcode

This comment has been minimized.

Copy link

wtdcode commented Oct 28, 2018

@layus Linking ~/.terminfo to /usr/share/terminfo works well on OpenWrt. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment