Packer: macOS terminal: output gets broken

Created on 14 Mar 2019  ยท  9Comments  ยท  Source: hashicorp/packer

@chrismarget and I noticed that our macOS Terminal output gets all messed up after Control+C'ing a build. This happened after updating our local packer git repos and building the latest ref in GitHub. It's almost like a return does not print a \n anymore.

This issue occurs in the latest commit in master. It does not occur in any existing packer releases - so you guys might already know about this.

Expected behavior

For a return to create a new line / not this :)

Work around

Execute reset followed by Control+L to redraw the screen.

Comments

Looking at master, this issue did not occur when I manually built a7078a1f9ba06ddca0cf2b278d003c3ab9c027e8. However, the issue occurs when building the commit immediately after (94d6fc10f5a754041889b14a480192ce8c8c748b). I am not sure why these changes caused this - but it might be a good place to look.

Most helpful comment

Thank you @vhaidamaka for the technical explanation and fix. I appreciate the super fast turn around from you and @azr!

All 9 comments

thanks for the heads-up. @azr wanna take a look?

The same behavior in the Debian buster.
GNU bash version 5.0.0(1)-release
Packer was built from the latest master.

Terminal line settings were captured by stty --all command before launch a packer (tty_normal) and after (tty_problem). stty is utility to change and print terminal line settings.
Here is the diff between line settings:

gnat@linux-pc:~/tty_params$ diff tty_normal tty_problem
6c6
< -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff
---
> -ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr -icrnl -ixon -ixoff
9c9
< isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
---
> isig -icanon iexten -echo echoe echok -echonl -noflsh -xcase -tostop -echoprt

icrnl option is disabled in terminal settings after the packer exit.
From man 1 stty input settings section: [-]icrnl translate carriage return to newline.
Opening new /dev/tty from main.go changes current terminal settings.

Howdy, a Close call was missing, thanks @vhaidamaka for pointing it out ! Can anyone please tell me if the binaries provided in #7411 fix this ?

Also, thanks for telling me about stty TIL. For me, output from stty is corrected after the fix too on macos.

I merged #7411 as I'm pretty sure it's the fix for this and it was getting in the way of other issue(s), please tell me if the problem persists, I'll investigate more.

@azr I just checked your binary in #7411 on Debian stretch, everything works correctly: terminal line settings is not changed after packer launch.
Thanks.

Awesome, great news ! Thanks for telling me @vhaidamaka

I just built 2c0f6944159d637b9242719882b9e1a8ecbbea15, the new Close() has improved my terminal experience on OSX.

Thank you @vhaidamaka for the technical explanation and fix. I appreciate the super fast turn around from you and @azr!

I'm going to lock this issue because it has been closed for _30 days_ โณ. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings