Skip to content
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

Closed
bbc2 opened this issue Feb 28, 2018 · 10 comments
Closed

fish: Could not set up terminal #36146

bbc2 opened this issue Feb 28, 2018 · 10 comments

Comments

@bbc2
Copy link

@bbc2 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
Copy link
Author

@bbc2 bbc2 commented Feb 28, 2018

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

@rembo10
Copy link
Contributor

@rembo10 rembo10 commented Sep 14, 2018

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

@layus
Copy link
Member

@layus 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
Copy link
Member

@layus 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
Copy link
Contributor

@rembo10 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
Copy link
Member

@layus 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
Copy link
Member

@layus 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
Copy link

@wtdcode wtdcode commented Oct 28, 2018

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

@stale
Copy link

@stale stale bot commented Jun 3, 2020

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.

@stale stale bot added the 2.status: stale label Jun 3, 2020
@layus
Copy link
Member

@layus layus commented Jun 3, 2020

@bbc2 I guess we can close the issue as this is is an upstream bug, with a known workaround. Feel free to reopen if need be.

@layus layus closed this Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants