charmbracelet / charmbracelet/bubbletea
"open /dev/tty: no such device or address" when running in Docker with no tty
- Dominant language
- Go
- Stars
- 44.9k
- Forks
- 1.3k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
It seems that when running inside a Docker container with no tty `Run()` returns an error:
```
open /dev/tty: no such device or address
```
**Setup**
Please complete the following information along with version numbers, if applicable.
- Ubuntu (docker)
**To Reproduce**
Simple bubbletea program:
```go
package main
import (
tea "github.com/charmbracelet/bubbletea"
)
type Model struct{}
func (m Model) Init() tea.Cmd {
return nil
}
func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, tea.Quit
}
func (m Model) View() string {
return ""
}
func main() {
_, err := tea.NewProgram(Model{}).Run()
if err != nil {
panic(err)
}
}
```
Build the binary for linux: `GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o ./main ./main.go`
Run in Docker: `docker run -v "$(pwd)"/main:/usr/local/bin/my-cli public.ecr.aws/ubuntu/ubuntu:22.04 my-cli`
```
panic: open /dev/tty: no such device or address
goroutine 1 [running]:
main.main()
/Users/jonbretman/code/bubbletea-tty-issue/main.go:24 +0x53
```
I'm using AWS Ubuntu because I discovered this issue while using my CLI tool in AWS CodeBuild, but the issue is not specific to AWS or CodeBuild (as far as I can tell). Running with `-it` works e.g. `docker run -it ...`
**Expected behavior**
I would expect the program to still run
Contributor guide
Assessment
This issue has not been assessed yet.