Works fine with packer 1.3.5 and 1.4.0 with Debug mode unchecked
Packer version: 1.4.0
Host platform: Ubuntu 16.04.6 LTS
Environment: Jenkins 2.164.2, Packer plugin: 1.4.0 (Debug enabled ONLY)
Packer template (full): https://gist.github.com/ahernyak/d4b284fdde6be8af485e94a93a66cd89
Log output: https://gist.github.com/ahernyak/913a0b6b4d7db7b6a30310585d4816cb
Crash log: https://gist.github.com/ahernyak/94c485eb3620ca112130f2013f87b3c3
@azr Looking at the logs, this is related to the TTY changes.
```2019/04/15 22:23:46 ui: ask: [1;32m==> cassandra us-east-2 builder: Pausing after run of step 'StepPreValidate'. Press enter to continue.[0m
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x10 pc=0x2270426]
goroutine 165 [running]:
github.com/hashicorp/packer/vendor/github.com/mattn/go-tty.(TTY).output(...)
/Users/mmarsh/go/src/github.com/hashicorp/packer/vendor/github.com/mattn/go-tty/tty_unix.go:101
github.com/hashicorp/packer/vendor/github.com/mattn/go-tty.(TTY).Output(0x0, 0x258b280)
/Users/mmarsh/go/src/github.com/hashicorp/packer/vendor/github.com/mattn/go-tty/tty.go:46 +0x6
github.com/hashicorp/packer/vendor/github.com/mattn/go-tty.(TTY).ReadString(0x0, 0x0, 0x0, 0x0, 0x0)
/Users/mmarsh/go/src/github.com/hashicorp/packer/vendor/github.com/mattn/go-tty/tty.go:90 +0x3c
github.com/hashicorp/packer/packer.(BasicUi).Ask.func1(0xc000402180, 0xc000402fc0)
/Users/mmarsh/go/src/github.com/hashicorp/packer/packer/ui.go:212 +0x40
created by github.com/hashicorp/packer/packer.(*BasicUi).Ask
```
Weird thing is that the line failing in the logs https://github.com/hashicorp/packer/blob/29e608e50508d8f142d5e43ff0ef686ff9014f95/packer/ui.go#L212
should be protected by this nil check: https://github.com/hashicorp/packer/blob/29e608e50508d8f142d5e43ff0ef686ff9014f95/packer/ui.go#L196-L198
Hey @ahernyak ! thanks for reporting ! Good catch @SwampDragons, the issue was that the interface type was set but the underlying object still nil, meaning that the if check will never be true
https://github.com/hashicorp/packer/blob/29e608e50508d8f142d5e43ff0ef686ff9014f95/packer/ui.go#L196-L198
Classic go gotcha, my bad !
I have a fix in #7517 please tell me if that fixed it for you.
Here's a binary in case: packer_linux_amd64.zip
I'm also experiencing this error on Windows 10 Packer 1.4.0:
goroutine 2028 [running]:
github.com/hashicorp/packer/vendor/github.com/mattn/go-tty.(TTY).readRune(0xc000062540, 0xc000000000, 0x0, 0x0)
/Users/mmarsh/go/src/github.com/hashicorp/packer/vendor/github.com/mattn/go-tty/tty_windows.go:209 +0xd33
github.com/hashicorp/packer/vendor/github.com/mattn/go-tty.(TTY).readString(0xc000062540, 0x1, 0xc0002f0010, 0x2df0c8d, 0x1, 0x2756d40)
/Users/mmarsh/go/src/github.com/hashicorp/packer/vendor/github.com/mattn/go-tty/tty.go:60 +0x70
github.com/hashicorp/packer/vendor/github.com/mattn/go-tty.(TTY).ReadString(0xc000062540, 0x0, 0x0, 0x0, 0x0)
/Users/mmarsh/go/src/github.com/hashicorp/packer/vendor/github.com/mattn/go-tty/tty.go:91 +0x95
github.com/hashicorp/packer/packer.(BasicUi).Ask.func1(0xc0002e4120, 0xc0006ab020)
/Users/mmarsh/go/src/github.com/hashicorp/packer/packer/ui.go:212 +0x47
created by github.com/hashicorp/packer/packer.(*BasicUi).Ask
/Users/mmarsh/go/src/github.com/hashicorp/packer/packer/ui.go:211 +0x23f
Here are some more binaries to test wether my fix worked:
windows_amd64.zip
darwin_amd64.zip
packer_linux_amd64.zip
I'd love some confirmation from one of the affected parties before we merge; can either of you test those binaries for us?
windows_amd64.zip posted above did not work. Still received error below. Same template and configuration is working on 1.3.5.
goroutine 1779 [running]:
github.com/hashicorp/packer/vendor/github.com/mattn/go-tty.(TTY).readRune(0xc000305240, 0xc000000000, 0x0, 0x0)
/Users/azr/go/src/github.com/hashicorp/packer/vendor/github.com/mattn/go-tty/tty_windows.go:209 +0xd33
github.com/hashicorp/packer/vendor/github.com/mattn/go-tty.(TTY).readString(0xc000305240, 0x1, 0xc000326058, 0x30ce96d, 0x1, 0x0)
/Users/azr/go/src/github.com/hashicorp/packer/vendor/github.com/mattn/go-tty/tty.go:60 +0x70
github.com/hashicorp/packer/vendor/github.com/mattn/go-tty.(TTY).ReadString(0xc000305240, 0x0, 0x0, 0x0, 0x0)
/Users/azr/go/src/github.com/hashicorp/packer/vendor/github.com/mattn/go-tty/tty.go:91 +0x95
github.com/hashicorp/packer/packer.(BasicUi).Ask.func1(0xc0004262a0, 0xc000742600)
/Users/azr/go/src/github.com/hashicorp/packer/packer/ui.go:212 +0x47
created by github.com/hashicorp/packer/packer.(*BasicUi).Ask
/Users/azr/go/src/github.com/hashicorp/packer/packer/ui.go:211 +0x23f
Hey @AndrewCi, thanks for trying, did you also get a No tty available
in your output log ? Please share your full logs so that I can see what happened.
The packer_linux_amd64.zip fixes the issue for me:
2019/04/17 18:44:45 [INFO] Packer version: 1.4.1-dev
2019/04/17 18:44:45 Packer Target OS/Arch: linux amd64
2019/04/17 18:44:45 Built with Go Version: go1.12.4
2019/04/17 18:44:45 Detected home directory from env var: /var/lib/jenkins
.......
2019/04/17 18:44:45 Build debug mode: true
........
2019/04/17 18:44:45 packer: 2019/04/17 18:44:45 [INFO] AWS Auth provider used: "SharedConfigCredentials: /var/lib/jenkins/.aws/credentials"
==> cassandra us-east-2 builder: Prevalidating AMI Name: cassandra-2.1.17-trusty-89
2019/04/17 18:44:46 packer: 2019/04/17 18:44:46 Error asking for input: no available tty
2019/04/17 18:44:46 packer: 2019/04/17 18:44:46 Using AMI Filters {
.......
@AndrewCi I can't reproduce on my Windows VM; can you share your packer template, and tell me what actions you're taking to get this error to happen?
Okay so #7517 fixes this issue ! Thanks for confirming @ahernyak !
@AndrewCi's issue is another one ( #7434) in the tty vendor that I fixed in #7452, I fixed it for unix but looking at the code it didn't seem it was going to happen for windows...
Reopening #7434.
Okay I have a fix, please tell me if it's better for you @AndrewCi,
Thank you for working on this. Unfortunately, it is still not working. It's hanging on an installation of ansible into a python virtualenv (specifically when pip is collecting the remote package and attempts to download the .tar). When I login to the server mid-build I validated that shell script generated from the inline shell builder ran successfully because everything installed properly. I also rolled back manually and re-executed the temporary shell script and it ran successfully as well. This leads to me to believe that for whatever reason Packer is dropping the connection mid-build or it's not able to receive confirmation back.
Again, the same exact template works perfectly on Packer 1.3.5.
Hmm. That hang may not be related to this same issue, then. Can you please open a new issue with all the information we need to reproduce this ourselves? (That includes a simple template that we can run to reproduce and test against, so we don't have to guess and go back and forth with you, full debug logs, and information about your environment and any script you may be using to call Packer.)
I made a separate issue #7525 because it doesn't appear to be isolated to the ansible provisioner itself, but might be an ansible issue in general.
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.