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

SSH to machine with fish gives: `fish: Could not set up terminal` #1060

Closed
terlar opened this Issue Oct 27, 2013 · 20 comments

Comments

Projects
None yet
10 participants
@terlar
Copy link
Contributor

terlar commented Oct 27, 2013

I have a machine I can not SSH into when it is running fish-shell as the shell. The strange thing is, if I use mosh instead of ssh it works. Or if I run ssh from within tmux then it works also. But never works when running directly from fish or bash launched under fish.

What could be causing this?

@zanchey

This comment has been minimized.

Copy link
Member

zanchey commented Oct 27, 2013

Intriguing! At a guess, your terminal type on your current system is not in the terminfo database on your target system.

This is produced when setupterm() errors, which can be caused by the following:

"1 means that the terminal is hardcopy, cannot be used for curses applications.
0 means that the terminal could not be found, or that it is a generic type, having too little information for curses applications to run.
-1 means that the terminfo database could not be found."

What terminal are you using? What is your $TERM? Does an entry for that terminal exist on the target system under /etc/terminfo, /lib/terminfo or /usr/lib/terminfo?

@terlar

This comment has been minimized.

Copy link
Contributor Author

terlar commented Oct 27, 2013

Sweet, that solved it.

I am using termite, it returns the $TERM xterm-termite. I copied over the terminfo for termite to the target system and it worked fine. Should have figured, but the message was a bit confusing.

@terlar terlar closed this Oct 27, 2013

@zanchey

This comment has been minimized.

Copy link
Member

zanchey commented Oct 27, 2013

Perhaps we could provide a better error message. What about "Check that your terminal is supported on this system"? It doesn't really provide a good way of solving the problem.

@terlar

This comment has been minimized.

Copy link
Contributor Author

terlar commented Oct 27, 2013

Yeah, the unfortunate thing would be if you cannot access this machine to change this. But I guess in most cases there are alternative means, could always set $TERM manually etc.

Your suggested message would help a little bit, one would know that the issue is with the target machine and that it is the identification of the terminal. Perhaps mention some section in the man pages also, for people totally unfamiliar with terminfo.

@zanchey zanchey reopened this Oct 28, 2013

@ridiculousfish

This comment has been minimized.

Copy link
Member

ridiculousfish commented Oct 28, 2013

I hope to drop the ncurses dependency and work with termcap directly, as zsh does.

@vikstrous

This comment has been minimized.

Copy link

vikstrous commented Nov 22, 2013

I ran into this. It was really confusing. I use fish + urxvt and when I tried to ssh into a system without urxvt installed it didn't have an entry for rxvt-unicode-256color in terminfo, so I had to install urxvt onto the system I'm sshing into so the entry gets added. An error message along the lines of $TERM not found in terminfo database. Change $$TERM or add entry for $TERM in terminfo database. would be helpful. This should be a warning and there should be some default instead of preventing me from loggin in.

@zanchey

This comment has been minimized.

Copy link
Member

zanchey commented Nov 24, 2013

vim assumes ansi if more specific terminal information is not available.

zanchey added a commit to zanchey/fish-shell that referenced this issue Nov 26, 2013

zanchey added a commit to zanchey/fish-shell that referenced this issue Nov 26, 2013

fall back to ANSI terminal type if setupterm fails
Closes: fish-shell#1060

'ansi' should always be present (tested on Solaris, Linux, FreeBSD,
Darwin).

Also overrides TERM so that other programs behave consistently e.g.
fish_pager.

The error message makes no specific mention of terminfo or termcap as
these vary across operating systems.
@zanchey

This comment has been minimized.

Copy link
Member

zanchey commented Nov 26, 2013

I have some changes that I would appreciate review on: https://github.com/zanchey/fish-shell/tree/terminfo-warn (zanchey/fish-shell@42b8619 and zanchey/fish-shell@2549fe5).

Testing and code review appreciated before I merge them to master.

@zanchey

This comment has been minimized.

Copy link
Member

zanchey commented Nov 26, 2013

The problem with specifically talking about the terminfo database is that:

  • sometimes it doesn't exist (FreeBSD uses termcap)
  • adding things to it requires root permissions, which not everyone has
  • adding things to it is complicated and system-dependent

So unfortunately I don't think we can give more specific guidance.

@xfix

This comment has been minimized.

Copy link
Member

xfix commented Nov 26, 2013

I wonder, could it be possible to assume some other terminal, even if it's unlikely to work.

~ $ env TERM=nonexistant fish
fish: Could not set up terminal

If I do this, fish just exits.

zanchey added a commit that referenced this issue Nov 26, 2013

fall back to ANSI terminal type if setupterm fails
Closes: #1060

'ansi' should always be present (tested on Solaris, Linux, FreeBSD,
Darwin).

Also overrides TERM so that other programs behave consistently e.g.
fish_pager.

The error message makes no specific mention of terminfo or termcap as
these vary across operating systems.

(r+ @ridiculousfish with thanks)
@zanchey

This comment has been minimized.

Copy link
Member

zanchey commented Nov 26, 2013

Now it should produce this output:

fish: Could not set up terminal
fish: Check that your terminal type, 'nonexistent', is supported on this system
fish: Attempting to use 'ansi' instead
bind: Key with name “dc” does not have any mapping
bind: Key with name “ppage” does not have any mapping
bind: Key with name “npage” does not have any mapping
bind: Key with name “f1” does not have any mapping

and operate at least partially.

@ghost ghost assigned zanchey Nov 26, 2013

@zanchey zanchey closed this Nov 26, 2013

@dolmen

This comment has been minimized.

Copy link

dolmen commented Dec 11, 2013

Note that adding a terminfo entry on a system does not requires to be root. You can have a per user terminfo database:

mkdir ~/.terminfo
export TERMINFO=~/.terminfo

Then you can compile terminfo entries (file.ti) from source.
For example, to copy a terminfo definition from the local machine to a remote:

infocmp | ssh $remote "cat > $TERM.ti ; tic -o ~/.terminfo $TERM.ti"

PS: sorry this is sh code, not fish code

@zanchey

This comment has been minimized.

Copy link
Member

zanchey commented Dec 30, 2013

That's useful to know, thanks.

krader1961 added a commit to krader1961/fish-shell that referenced this issue Jun 3, 2016

put curses/terminfo vars into the environment
We need to actually export the curses/terminfo env vars in order for
`setupterm()` to be able to use them. While fixing this I reworked the
fallback logic implemented by @zanchey in response to issue fish-shell#1060 in
order to simplify the logic and clarify the error messages.

This does not allow someone to change the curses/terminfo env vars after
the first prompt is displayed (you can but it won't affect the current
fish process). It only makes it possible to set `TERM`, `TERMINFO`, and
`TERMINFO_DIRS` in *config.fish* or similar config file and have them be
honored by fish.

krader1961 added a commit that referenced this issue Jun 4, 2016

put curses/terminfo vars into the environment
We need to actually export the curses/terminfo env vars in order for
`setupterm()` to be able to use them. While fixing this I reworked the
fallback logic implemented by @zanchey in response to issue #1060 in
order to simplify the logic and clarify the error messages.

This does not allow someone to change the curses/terminfo env vars after
the first prompt is displayed (you can but it won't affect the current
fish process). It only makes it possible to set `TERM`, `TERMINFO`, and
`TERMINFO_DIRS` in *config.fish* or similar config file and have them be
honored by fish.

krader1961 added a commit that referenced this issue Jun 21, 2016

put curses/terminfo vars into the environment
We need to actually export the curses/terminfo env vars in order for
`setupterm()` to be able to use them. While fixing this I reworked the
fallback logic implemented by @zanchey in response to issue #1060 in
order to simplify the logic and clarify the error messages.

This does not allow someone to change the curses/terminfo env vars after
the first prompt is displayed (you can but it won't affect the current
fish process). It only makes it possible to set `TERM`, `TERMINFO`, and
`TERMINFO_DIRS` in *config.fish* or similar config file and have them be
honored by fish.
@kyleholzinger

This comment has been minimized.

Copy link

kyleholzinger commented Feb 20, 2017

Just a little note, I had this issue and it was due to a small mistake when writing my fish config. I had:

set -gx TERM "xterm-256color" set -gx LSCOLORS "lksjakdjasdlk"

Looks like this causes fish to die immediately.

@faho

This comment has been minimized.

Copy link
Member

faho commented Feb 25, 2017

@kyleholzinger: What fish version did you use with that? For me, fish screams about not being able to setup the terminal, but then goes on with a fallback TERM=ansi.

@kyleholzinger

This comment has been minimized.

Copy link

kyleholzinger commented Feb 26, 2017

@faho I think 2.4.

@faho

This comment has been minimized.

Copy link
Member

faho commented Feb 26, 2017

In that case, you'll be happy to hear that there have been fixes in this area since then.

Also, you should not set $TERM in config.fish. Your terminal should set it properly. If it doesn't, complain to them or if it has a configuration knob for it, change it there. The reason for this is that we use $TERM for plenty of things, like detecting how many colors it supports (if this goes wrong, you'll see weird output) and detecting what sequence means what key combination (if this goes wrong, your binds will go weird). We also integrate with some special terminal features - in vte or terminal.app, we send the PWD specially (if this goes wrong, you'll once again see weird crap).

@krisavi

This comment has been minimized.

Copy link

krisavi commented Apr 19, 2017

I have same issue, but with custom made terminal sets. Combined 2 of the sets like "linux" and "rxtv-unicode-256color" to make "linux-256color". Well actually it even supports 24bit colors. After adding it as root it actually connected to fish shell without problems, but the shell is extremely slow and laggy. Seems to lag every time it tries to do any kind of character change on screen or show some suggestions...

Ansi fallback causes more problems, like screen popping up on autocompletion and overwriting text I was even typing.

How can I force it to use 24bit or 256 color fish terminal mode?

Weird is that it seems to work fine on non-root mode, huge lag when on fish shell as root.

@faho

This comment has been minimized.

Copy link
Member

faho commented Apr 19, 2017

I have same issue, but with custom made terminal sets. Combined 2 of the sets like "linux" and "rxtv-unicode-256color" to make "linux-256color"

You mean you made your own terminfo entry? I can only advise against that, since the remote machine won't have it so anything that uses terminfo will have issues.

And in this case specifically, using the "linux" entry makes no sense since that's the one for the kernel vt (the thing you get when you press ctrl+alt+fX), which is a rather... special kind of terminal, that supports very few things.

Unless of course you've patched your kernel to do 24bit color, in which case kudos to you and I'm eagerly awaiting upstream inclusion! 😄

Or do you use rxvt? I wasn't aware that could do 24bit either.

How can I force it to use 24bit or 256 color fish terminal mode?

Currently, the one knob we have for 24bit mode is a force-toggle. Set $fish_term24bit to 1 and it should use 24bit colors. However, other things like keybindings and such might have issues.

Weird is that it seems to work fine on non-root mode, huge lag when on fish shell as root.

That actually points to it being caused by something different - how do you get root? By directly logging in or su? We've just merged a patch that works around some weird and unintuitive su behavior (it doesn't change $HOME when the target user is root), that might change something here.

@krader1961

This comment has been minimized.

Copy link
Contributor

krader1961 commented Apr 20, 2017

@krisavi, If @faho's feedback doesn't help please open a new issue. The problem you're describing is nothing like the problem this issue dealt with. Also, if you do open a new issue please provide some details such as the OS you're using, the terminal emulator, and the value of $TERM when running fish as root and a non-root user.

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