caddy: Running Caddy breaks terminal, ANSI escape codes are printed
After running Caddy with any command, the terminal breaks.
Non-printable keys print their ANSI escape sequence instead, (e.g. up arrow prints ^[[A and ctrl+c prints ^C).

OS: Windows Server 2016 Datacenter (Version 10.0.14393, Build 14393) Caddy Version: v2.4.3 h1:Y1FaV2N4WO3rBqxSYA8UZsZTQdN+PwcoOcAiZTM8C0I=
This happens with both Command Prompt and PowerShell (v5). I have a separate installation of PowerShell 7 that is unaffected.
This looks like the same issue as #4212
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Reactions: 1
- Comments: 15 (10 by maintainers)
Commits related to this issue
- fix: retaina and restore terminal mode on Windows (fixes #4251) — committed to caddyserver/caddy by mohammed90 3 years ago
- fix: retain and restore terminal mode on Windows Fixes #4251 — committed to caddyserver/caddy by mohammed90 3 years ago
Dependency https://github.com/smallstep/cli-utils/blob/17e7ebecb8b9cc1cbf7958a2dcd69a63af8f710c/ui/ui_windows.go#L10 enables virtual terminal input and processing but never restores it.
@mholt @francislavoie Replacing replacing go.step.sm/cli-utils should fix it.
We will merge https://github.com/smallstep/certificates/pull/719 soon too. When this happens
go get github.com/smallstep/certificates@master && go mod tidywill also fix the issueI tested the dev build and the issue has been fixed.
Thank you very much for investigating and chiming in, @egonelbre! I prefer option 2 personally. Thanks for the patch though Mohammed, but in the nicest way possible I hope we don’t have to use it. 😂
Can any of the impacted users verify the fix in the PR #4369? You can grab the CI build artifact from here: https://github.com/caddyserver/caddy/actions/runs/1301313398#artifacts
The solution is either:
Unfortunately, don’t have time to dig deeper to implement the solution. It was more of a drive-by debugging, since I’ve seen similar issues before.
It’s not actually the printing of the version what causes the terminal to stop breaking. I have the same problem (Windows 10, Build 19041.1083) Any execution of caddy in a terminal window for any command has the same result.
This happens in cmd and in other command prompts like TCC/Take Command.