Skip to content

3052: clean exit #3075

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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

KevinGimbel
Copy link

A wrong TERM value can cause k9s to crash, instead of crashing we can log a warning and silently set the variable for the duration of k9s' execution with os.Setenv. We recommend setting this variable in the README.md anyway (during the Preflight checks)

I've tested it with MacOS and would like to test on Linux as well.

How to test

Set TERM to xterm-ghostty

export TERM=xterm-ghostty

Run k9s, it panics:

k9s
panic: exit status 1

goroutine 1 [running]:
github.com/derailed/k9s/cmd.Execute()
        github.com/derailed/k9s/cmd/root.go:72 +0x80
main.main()

Run this branch, it works:

go run main.go
WARN: $TERM must be set to 'xterm-256color', got 'xterm-ghostty'
<k9s starts normally>

Set TERM variable if it is anything but xterm-256color,
this prevents panics and crashes, and logs a warning as well.

Updates derailed#3052
@KevinGimbel
Copy link
Author

I accidentally added a WIP from another local branch to this PR, which I reverted again. I can also scrap and re-create the entire PR / branch if needed. :)

@KevinGimbel
Copy link
Author

@derailed anything else I can do so we can merge this MR? Seems to be low hanging fruits IMHO :)

@derailed
Copy link
Owner

@KevinGimbel Thanks Kevin! No sure we want to automatically set this. I think it make sense for nix platforms but not sure how it should work on other. Also this is documented and you should only have to do this once if misconfigured??

@derailed derailed added enhancement New feature or request question Further information is requested labels Feb 16, 2025
@KevinGimbel
Copy link
Author

@derailed I agree about the documentation, but it feel like it came up more often over the past weeks although I now only find (#3052) with a clear reference.

Maybe an exit and link to the documentation would work? I feel as it is people may be discouraged from using k9s if it fails silently.

@derailed
Copy link
Owner

@KevinGimbel Tx Kevin! I think that's a great idea.

@KevinGimbel
Copy link
Author

@derailed I completely forgot about this PR 🙈 - I replaced the code so that the variable is not set automatically. Instead a Link to the documentation is printed and k9s exits with status code 1.

Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Apr 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants