gliderlabs / cmd

Other
28 stars 4 forks source link

document workaround for xterm-256color #101

Open progrium opened 7 years ago

progrium commented 7 years ago

Once Cmd.io gets the latest SSH package update that has better PTY support (including use of TERM), users (esp those on Lion) may run into this error:

Error opening terminal: xterm-256color.

I don't fully grok everything going on (is it Docker complaining about terminal type? the system via docker? the image? the program in the image?), but the problem isn't specific to Cmd.io or Docker:

https://www.cloudfarm.it/fix-error-opening-terminal-xterm-256color-unknown-terminal-type/

euank commented 7 years ago

Unknown terminal type often means that the "terminfo" isn't available for that identifer (e.g. in /usr/share/terminfo).

It probably refers to the image's terminfo, but I'm not totally sure.

Because Docker translates -t into TERM=xterm (see https://github.com/docker/docker/blob/c3b660b112804dfb1752efc1368a104897c7b884/container/container_unix.go#L62-L64), images can get away with only including xterm's terminfo and so many do, and regular docker users won't notice anything missing even if their TERM is totally different.

I'm surprised that TERM is being set at all for the docker container.. is there code actively passing through env variables? Is the code not setting "Tty: true" and thus not causing docker to set TERM=xterm?

progrium commented 7 years ago

If you explicitly set TERM, Docker will use that. At least in 1.13. And yes, I think since normally when you use Docker people don't think to set TERM, but since we just implemented more PTY support of SSH, we do get the user's TERM in the PTY request and then explicitly set it. Users can override this by setting their own env via the Cmd.io env command.

(This is all since a PR that has not yet landed in alpha, but should be soon)

That said, if Docker can get away with just setting TERM=xterm maybe we can force xterm-256color to xterm unless the user explicitly sets otherwise? However, one thing to consider is that explicitly setting forces it for all users of the command. Thoughts?