flyctl ssh console - no up arrow? no back arrow? no forward delete / home / end etc.?

My PHP codebase is using a Dockerfile from this project GitHub - hyperf/hyperf-skeleton: 🛠 A skeleton of Hyperf framework that provided by official team
Seems to be using Alpine linux
Deploying to works fine
But trying to log in remotely over console flyctl ssh console seems to be missing basic terminal features like up arrow, back arrow, forward-delete, Home/End keys etc. instead these keys seem to spam control characters into the command line…
Switching from sh to bash doesn’t help, still these basic terminal functionalities are missing…

Is there something to adjust in the environment / TERM or something? Is the image missing some basic system packages? Is using it from CMD/PowerShell on windows the problem? How can I fix this please

What OS do you run flyctl ssh console on?

If it is a Windows machine then you are out of luck as for now. But you can use Windows Subsystem for Linux.

I think flyctl is missing SetConsoleMode(hOut, dwMode | ENABLE_VIRTUAL_TERMINAL_PROCESSING | ENABLE_VIRTUAL_TERMINAL_INPUT) call and it effectively leaves virtual terminal emulation in Windows unused. More info: Console Virtual Terminal Sequences - Windows Console | Microsoft Learn

I am too will be happy to see this problem fixed. Here is the corresponding GitHub issue for everyone interested:

1 Like

Thanks for this analysis. I just submitted Enable virtual terminal processing for STDOUT/STDIN under Windows. by ndarilek · Pull Request #1591 · superfly/flyctl · GitHub which seems to fix this.

The only bit I’m not entirely certain about is my use of the init func to enable this functionality under Windows. Essentially init is what I want, but I’m guessing this enables VT support everywhere, which may or may not be desirable. If any Golang pros know of a better way then I’m open to feedback–Rust developer learning Go and still getting to grips with it.

But I did verify that without this fix, SSHing into an app and running commands under /bin/bash doesn’t handle command history and such. With it, it does.


Looks good to me. However, your concern about init may be important in stdin/stdout redirection scenarios. You have to ensure that redirected commands still work, e.g.:

> flyctl > 1.txt

should not produce the following error:

failed to enable virtual terminal processing for stdout

The init code looks good and should not cause that error, but it is better to check that scenario, just in case.

Thanks for that tip–I’ve not done a lot of mucking around with the Windows console before.

I’ve confirmed that the PR doesn’t seem to exhibit this behavior. Starting an interactive SSH session at least handles up-arrow through command history, and go run ./main.go help > log does indeed redirect help output to the file.

Please let me know if there are any other scenarios I should check. Hoping to get this one merged next week and released soon after.’

Thanks again.

Console became broken again in one of the recent flyctl updates. I have the version below and virtual terminal emulation does not work anymore:

> flyctl.exe v0.0.488 windows/amd64 Commit: d56b165d BuildDate: 2023-03-15T14:36:24Z