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

Bug on Kitty: Terminfo file not found #59

Open
thiswillbeyourgithub opened this issue Jun 19, 2024 · 8 comments
Open

Bug on Kitty: Terminfo file not found #59

thiswillbeyourgithub opened this issue Jun 19, 2024 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@thiswillbeyourgithub
Copy link

What happened
I can't create shpool sessions in kitty-terminal but I can with gnome-terminal.
Here's the output that appears in journalctl -f:

ThreadId(07) handling new connection: resolving terminfo
REDACTED shpool[2274258]: Caused by:
REDACTED shpool[2274258]:     Terminfo file not found

Here are relevant outputs in my kitty:

❯ echo $TERMINFO
/home/$USER/.local/kitty.app/lib/kitty/terminfo
❯ echo $TERM
xterm-kitty

And on gnome-terminal:

[11:51]echo $TERMINFO
/home/USER/.local/kitty.app/lib/kitty/terminfo
[11:51]>echo $TERM
xterm-256color

So I tried this in kitty: TERM="xterm-256color" shpool attach -f "test" and it worked directly.

What I expected to happen
First, this error should appear not only in journalctl but to the user that called it! I get no feedback that shpool failed except that shpool list shows an empty list.
Then, the error is incorrect: it should not be "Terminfo" file not found (the file is found) but has to do with $TERM.

To Reproduce
Steps to reproduce the behavior:

  1. Run `journalctl -f | grep shpool
  2. In gnome-terminal (=a working shpool terminal) run TERM="xterm-kitty" shpool attach -f "test"
  3. Notice the absence of error in the shell
  4. Notice the error in the journal

Version info
shpool 0.6.2

Logs

shpool[2274258]: INFO ThreadId(01) run:serve: socket got a new connection
shpool[2274258]: INFO ThreadId(33) handle_conn{cid=14}: new
shpool[2274258]: INFO ThreadId(33) handle_conn{cid=14}:parse_connect_header: new
shpool[2274258]: INFO ThreadId(33) handle_conn{cid=14}:parse_connect_header: close time.busy=88.6µs time.idle=12.6µs
shpool[2274258]: INFO ThreadId(33) handle_conn{cid=14}:handle_attach: new
shpool[2274258]: INFO ThreadId(33) handle_conn{cid=14}:handle_attach: locked shells table
shpool[2274258]: INFO ThreadId(33) handle_conn{cid=14}:handle_attach: no existing 'test' session, creating new one
shpool[2274258]: INFO ThreadId(33) handle_conn{cid=14}:handle_attach: creating new subshell
shpool[2274258]: INFO ThreadId(33) handle_conn{cid=14}:handle_attach:spawn_subshell: new
shpool[2274258]: INFO ThreadId(33) handle_conn{cid=14}:handle_attach:spawn_subshell: user_info=Info { default_shell: "/bin/zsh", home_dir: "/home/USER", user: "USER" }
shpool[2274258]: INFO ThreadId(33) handle_conn{cid=14}:handle_attach:spawn_subshell:inject_env: new
shpool[2274258]: INFO ThreadId(33) handle_conn{cid=14}:handle_attach:spawn_subshell:inject_env: injecting TERM into shell Some("xterm-kitty")
shpool[2274258]: INFO ThreadId(33) handle_conn{cid=14}:handle_attach:spawn_subshell:inject_env: close time.busy=40.3µs time.idle=6.14µs
shpool[2274258]: INFO ThreadId(33) handle_conn{cid=14}:handle_attach:spawn_subshell: close time.busy=194µs time.idle=5.47µs
shpool[2274258]: INFO ThreadId(33) handle_conn{cid=14}:handle_attach: close time.busy=248µs time.idle=8.34µs
shpool[2274258]: INFO ThreadId(33) handle_conn{cid=14}: close time.busy=433µs time.idle=24.7µs
shpool[2274258]: ERROR ThreadId(33) handling new connection: resolving terminfo
shpool[2274258]: Caused by:
shpool[2274258]:     Terminfo file not found
@ethanpailes
Copy link
Contributor

Thanks for the report.

Hopefully all we need to do here is just warn or fallback to xterm if we can't resolve terminfo.

ethanpailes added a commit that referenced this issue Jun 21, 2024
This patch will hopefully address #59. Unfortunately,
I wasn't able to write a test to reproduce the issue,
so it is just a blind fix.
@ethanpailes
Copy link
Contributor

@thiswillbeyourgithub, I wasn't able to repro, but I wrote a blind patch that should hopefully work (#62). If you're up for it, I would appreciate it if you could try building that branch and seeing if it fixes the problem.

After cloning the repo and checking out the branch, you can test out shpool by doing

cargo run -- -s /tmp/shpool.sock daemon

then

cargo run -- -s /tmp/shpool.sock attach testsession

in order to attach. This way you won't disturb any existing shpool daemon you have running.

ethanpailes added a commit that referenced this issue Jun 21, 2024
This patch will hopefully address #59. Unfortunately,
I wasn't able to write a test to reproduce the issue,
so it is just a blind fix.
@ethanpailes ethanpailes self-assigned this Jun 21, 2024
@thiswillbeyourgithub
Copy link
Author

Thanks a lot! I'll check in a couple of days max

ethanpailes added a commit that referenced this issue Jun 21, 2024
This patch will hopefully address #59. Unfortunately,
I wasn't able to write a test to reproduce the issue,
so it is just a blind fix.
@thiswillbeyourgithub
Copy link
Author

Well actually I tested now and it seems to join fine BUT to my great surprise inside the shpool session the arrow keys and backspace are completely broken, they seam to repeat some strings instead of doing their original function.

Nothing in my .zshrc has anything to do with that AFAIK

@ethanpailes
Copy link
Contributor

We fall back to xterm terminfo if we can't find the terminfo based off of $TERM, so maybe kitty uses different control codes from xterm for arrow keys? That seems pretty weird though, I would imagine those are pretty standard. Also, shpool doesn't do anything with regard to arrow keys, just passed them through like everything else. We use the termini create for terminfo, so maybe if you can set things up so that it can find your terminfo file things will be different. I notice you have $TERMINFO pointing to some local file. One thing to try would be to put TERMINFO in forward_env since that might not be getting forwarded to the shpool session (if that works for you we should probably add it to the default set).

It might be worth capturing your shell output with and without shpool in the loop and then comparing the bytes to see if there is a difference in the control codes coming back to kitty.

@ethanpailes
Copy link
Contributor

I can also try installing kitty rather than just messing with TERM in tests to repro. That may take a bit though since my normal computer is having some trouble.

@thiswillbeyourgithub
Copy link
Author

Unfortunately I know very little about how terminals work so it might be the best way forward :/ I'm very interested in shpool (as tmux can't work with kitty) but am holding off until the dust settles and the kitty issues are more well known.

I recommend giving kitty a try! Especially the timecoded video the author made to showcase features: https://sw.kovidgoyal.net/kitty/

@ethanpailes ethanpailes added the bug Something isn't working label Jun 24, 2024
@thiswillbeyourgithub
Copy link
Author

thiswillbeyourgithub commented Jun 28, 2024

Update: I noticed today that when I do "sudo su" in a terminal, my session seems to have the same issue: pressing backspace seemed to be the spacebar and the arrow keys were funky. None of this is related to shpool, I'm talking about a kitty issue.

So I found this kitty issue where the dev suggests adding this to visudo: Defaults env_keep += "TERMINFO" and it solved this kitty issue.

So I tried again your patch and it seems to work fine now.

AFAIC you can merge it.

edit: had linked the wrong issue!

ethanpailes added a commit that referenced this issue Jul 9, 2024
This patch will hopefully address #59. Unfortunately,
I wasn't able to write a test to reproduce the issue,
so it is just a blind fix.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants