fix: unset TERMINFO before keyboard.Open() to fix tmux terminal support - #340
Open
octo-patch wants to merge 1 commit into
Open
Conversation
When a terminal emulator (e.g. Ghostty) sets $TERMINFO to a private directory containing only its own terminfo entries, the eiannone/keyboard library uses that path exclusively and fails to locate tmux-256color when running inside tmux, producing an "Unsupported terminal" error. Temporarily unsetting $TERMINFO before keyboard.Open() allows the library to fall through to $TERMINFO_DIRS and standard system paths where tmux-256color is available. The variable is restored via defer once the function returns. Fixes plandex-ai#320
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #320
Problem
When a terminal emulator (e.g. Ghostty) sets
$TERMINFOto a private directory containing only its own terminfo entries, theeiannone/keyboardlibrary uses that directory exclusively — it does not fall through to$TERMINFO_DIRSor standard system paths. As a result, when running inside tmux, the library cannot locatetmux-256colorand returns an "Unsupported terminal" error, which surfaces as:This affects any user whose terminal sets
$TERMINFOto a terminal-specific directory (Ghostty, Alacritty with custom terminfo, etc.) when also using tmux.Solution
Temporarily unset
$TERMINFOinsideGetUserKeyInput()before callingkeyboard.Open(). This allows the library to search$TERMINFO_DIRSand standard system paths (e.g./usr/share/terminfo) wheretmux-256coloris available. The original value is restored viadeferwhen the function returns.The change is limited to the keyboard open call and does not affect any other behavior.
Testing
Reproduced locally by setting
TERMINFO=/tmp/empty-terminfo TERM=tmux-256colorand confirming that without the fixkeyboard.Open()fails, while with the fix it succeeds by falling through to system terminfo paths.