opencode: [0.2.6] pasting with ctrl+v crashes the program.

Version: 0.2.6 Terminal emulator: alacritty Running with tmux: yes window manager: awesomewm with xorg

Steps to reproduce:

  • copy some string
  • run opencode
  • press ctrl+v

this will crash the program with the following output:

Caught panic:

clipboard: cannot use when CGO_ENABLED=0

Restoring terminal...

goroutine 1 [running]:
runtime/debug.Stack()
        /opt/hostedtoolcache/go/1.24.4/x64/src/runtime/debug/stack.go:26 +0x5e
runtime/debug.PrintStack()
        /opt/hostedtoolcache/go/1.24.4/x64/src/runtime/debug/stack.go:18 +0x13
github.com/charmbracelet/bubbletea/v2.(*Program).recoverFromPanic(0xc0004ce200, {0xbd99e0, 0x106b3a0})
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.3/tea.go:1134 +0xc5
github.com/charmbracelet/bubbletea/v2.(*Program).Run.func2()
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.3/tea.go:871 +0xe8
panic({0xbd99e0?, 0x106b3a0?})
        /opt/hostedtoolcache/go/1.24.4/x64/src/runtime/panic.go:792 +0x132
golang.design/x/clipboard.read(...)
        /home/runner/go/pkg/mod/golang.design/x/clipboard@v0.7.1/clipboard_nocgo.go:12
golang.design/x/clipboard.Read(0x0?)
        /home/runner/go/pkg/mod/golang.design/x/clipboard@v0.7.1/clipboard.go:119 +0x85
github.com/sst/opencode/internal/components/chat.(*editorComponent).Paste(0xc000b22008)
        /home/runner/work/opencode/opencode/packages/tui/internal/components/chat/editor.go:332 +0x37
github.com/sst/opencode/internal/tui.appModel.executeCommand({0xbe, 0x33, 0xc000b08288, {0x0, 0x0}, {0x7a4407a39578, 0xc00050feb0}, {0x10793c8, 0xc000b22008}, {0x1079340, ...}, ...}, ...)
        /home/runner/work/opencode/opencode/packages/tui/internal/tui/tui.go:908 +0x7c9
github.com/sst/opencode/internal/tui.appModel.Update({0xbe, 0x33, 0xc000b08288, {0x0, 0x0}, {0x7a4407a39578, 0xc00050feb0}, {0x10793c8, 0xc000b22008}, {0x1079340, ...}, ...}, ...)
        /home/runner/work/opencode/opencode/packages/tui/internal/tui/tui.go:344 +0x2ac5
github.com/charmbracelet/bubbletea/v2.(*Program).eventLoop(0xc0004ce200, {0x1070c18?, 0xc000b0d508?}, 0xc0000e81c0)
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.3/tea.go:767 +0x16e6
github.com/charmbracelet/bubbletea/v2.(*Program).Run(0xc0004ce200)
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.3/tea.go:1022 +0xe76
main.main()
        /home/runner/work/opencode/opencode/packages/tui/cmd/opencode/main.go:106 +0xa98

Running with CGO_ENABLED=1 opencode doesn’t change the output.

pasting with ctrl+shift+v fixes the issue

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 1
  • Comments: 23

Most upvoted comments

my bad, i thought it was only an issue on darwin, will fix for linux as well, might be early AM tomorrow, apologies!

i’m working on this now, sorry

My setup is still crashing since 0.2.6 (using 0.2.13 now). My setup:

Main OS: Windows 11 Pro 10.0.26100 Build 26100 WSL OS: Ubuntu 24.04.2 LTS (GNU/Linux 5.15.153.1-microsoft-standard-WSL2 x86_64) Ghosty: ghostty version=1.1.3 Workaround: Use something other than Ghostty (e.g., Windows Terminal).

Ghostty started crashing on 0.2.6 as 0.2.5 is working. Stacktrace for 0.2.6:

Caught panic:

clipboard: cannot use when CGO_ENABLED=0

Restoring terminal...

goroutine 1 [running]:
runtime/debug.Stack()
        /opt/hostedtoolcache/go/1.24.4/x64/src/runtime/debug/stack.go:26 +0x5e
runtime/debug.PrintStack()
        /opt/hostedtoolcache/go/1.24.4/x64/src/runtime/debug/stack.go:18 +0x13
github.com/charmbracelet/bubbletea/v2.(*Program).recoverFromPanic(0xc00026c200, {0xbd99e0, 0x106b3a0})
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.3/tea.go:1134 +0xc5
github.com/charmbracelet/bubbletea/v2.(*Program).Run.func2()
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.3/tea.go:871 +0xe8
panic({0xbd99e0?, 0x106b3a0?})
        /opt/hostedtoolcache/go/1.24.4/x64/src/runtime/panic.go:792 +0x132
golang.design/x/clipboard.read(...)
        /home/runner/go/pkg/mod/golang.design/x/clipboard@v0.7.1/clipboard_nocgo.go:12
golang.design/x/clipboard.Read(0x0?)
        /home/runner/go/pkg/mod/golang.design/x/clipboard@v0.7.1/clipboard.go:119 +0x85
github.com/sst/opencode/internal/components/chat.(*editorComponent).Paste(0xc00024aa08)
        /home/runner/work/opencode/opencode/packages/tui/internal/components/chat/editor.go:332 +0x37
github.com/sst/opencode/internal/tui.appModel.executeCommand({0xc8, 0x2d, 0xc000b68288, {0x0, 0x0}, {0x7efd17a2afb8, 0xc001f027c0}, {0x10793c8, 0xc00024aa08}, {0x1079340, ...}, ...}, ...)
        /home/runner/work/opencode/opencode/packages/tui/internal/tui/tui.go:908 +0x7c9
github.com/sst/opencode/internal/tui.appModel.Update({0xc8, 0x2d, 0xc000b68288, {0x0, 0x0}, {0x7efd17a2afb8, 0xc001f027c0}, {0x10793c8, 0xc00024aa08}, {0x1079340, ...}, ...}, ...)
        /home/runner/work/opencode/opencode/packages/tui/internal/tui/tui.go:344 +0x2ac5
github.com/charmbracelet/bubbletea/v2.(*Program).eventLoop(0xc00026c200, {0x1070c18?, 0xc000b6d508?}, 0xc0002c0230)
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.3/tea.go:767 +0x16e6
github.com/charmbracelet/bubbletea/v2.(*Program).Run(0xc00026c200)
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.3/tea.go:1022 +0xe76
main.main()
        /home/runner/work/opencode/opencode/packages/tui/cmd/opencode/main.go:106 +0xa98

v0.2.12 Stacktrace

Caught panic:

runtime error: index out of range [-1]

Restoring terminal...

goroutine 1 [running]:
runtime/debug.Stack()
        /opt/hostedtoolcache/go/1.24.4/x64/src/runtime/debug/stack.go:26 +0x5e
runtime/debug.PrintStack()
        /opt/hostedtoolcache/go/1.24.4/x64/src/runtime/debug/stack.go:18 +0x13
github.com/charmbracelet/bubbletea/v2.(*Program).recoverFromPanic(0xc0005c8200, {0xc90240, 0xc000268198})
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.3/tea.go:1134 +0xc5
github.com/charmbracelet/bubbletea/v2.(*Program).Run.func2()
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.3/tea.go:871 +0xe8
panic({0xc90240?, 0xc000268198?})
        /opt/hostedtoolcache/go/1.24.4/x64/src/runtime/panic.go:792 +0x132
golang.design/x/clipboard.read(0x1)
        /home/runner/work/opencode/opencode/packages/tui/clipboard/clipboard_linux.go:102 +0x189
golang.design/x/clipboard.Read(0x0?)
        /home/runner/work/opencode/opencode/packages/tui/clipboard/clipboard.go:119 +0x9e
github.com/sst/opencode/internal/components/chat.(*editorComponent).Paste(0xc000238a08)
        /home/runner/work/opencode/opencode/packages/tui/internal/components/chat/editor.go:332 +0x37
github.com/sst/opencode/internal/tui.appModel.executeCommand({0xc8, 0x2d, 0xc000b60288, {0x0, 0x0}, {0x7f810aacefb8, 0xc000d02560}, {0x107b9a8, 0xc000238a08}, {0x107b920, ...}, ...}, ...)
        /home/runner/work/opencode/opencode/packages/tui/internal/tui/tui.go:908 +0x7c9
github.com/sst/opencode/internal/tui.appModel.Update({0xc8, 0x2d, 0xc000b60288, {0x0, 0x0}, {0x7f810aacefb8, 0xc000d02560}, {0x107b9a8, 0xc000238a08}, {0x107b920, ...}, ...}, ...)
        /home/runner/work/opencode/opencode/packages/tui/internal/tui/tui.go:344 +0x2ac5
github.com/charmbracelet/bubbletea/v2.(*Program).eventLoop(0xc0005c8200, {0x10731f8?, 0xc000b65508?}, 0xc0005a81c0)
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.3/tea.go:767 +0x16e6
github.com/charmbracelet/bubbletea/v2.(*Program).Run(0xc0005c8200)
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.3/tea.go:1022 +0xe76
main.main()
        /home/runner/work/opencode/opencode/packages/tui/cmd/opencode/main.go:106 +0xa98

v0.2.13 Stacktrace

Caught panic:

runtime error: index out of range [-1]

Restoring terminal...

goroutine 1 [running]:
runtime/debug.Stack()
        /opt/hostedtoolcache/go/1.24.4/x64/src/runtime/debug/stack.go:26 +0x5e
runtime/debug.PrintStack()
        /opt/hostedtoolcache/go/1.24.4/x64/src/runtime/debug/stack.go:18 +0x13
github.com/charmbracelet/bubbletea/v2.(*Program).recoverFromPanic(0xc00022c400, {0xc90320, 0xc000b196f8})
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.3/tea.go:1134 +0xc5
github.com/charmbracelet/bubbletea/v2.(*Program).Run.func2()
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.3/tea.go:871 +0xe8
panic({0xc90320?, 0xc000b196f8?})
        /opt/hostedtoolcache/go/1.24.4/x64/src/runtime/panic.go:792 +0x132
golang.design/x/clipboard.read(0x1)
        /home/runner/work/opencode/opencode/packages/tui/clipboard/clipboard_linux.go:102 +0x189
golang.design/x/clipboard.Read(0x0?)
        /home/runner/work/opencode/opencode/packages/tui/clipboard/clipboard.go:119 +0x9e
github.com/sst/opencode/internal/components/chat.(*editorComponent).Paste(0xc000bbc008)
        /home/runner/work/opencode/opencode/packages/tui/internal/components/chat/editor.go:342 +0x37
github.com/sst/opencode/internal/tui.appModel.executeCommand({0xc8, 0x2d, 0xc000b58288, {0x0, 0x0}, {0x7f7ffa978538, 0xc000b2fdc0}, {0x107c3f8, 0xc000bbc008}, {0x107bde0, ...}, ...}, ...)
        /home/runner/work/opencode/opencode/packages/tui/internal/tui/tui.go:949 +0x7a9
github.com/sst/opencode/internal/tui.appModel.Update({0xc8, 0x2d, 0xc000b58288, {0x0, 0x0}, {0x7f7ffa978538, 0xc000b2fdc0}, {0x107c3f8, 0xc000bbc008}, {0x107bde0, ...}, ...}, ...)
        /home/runner/work/opencode/opencode/packages/tui/internal/tui/tui.go:381 +0x2b38
github.com/charmbracelet/bubbletea/v2.(*Program).eventLoop(0xc00022c400, {0x10736b8?, 0xc000b5d508?}, 0xc000564380)
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.3/tea.go:767 +0x16e6
github.com/charmbracelet/bubbletea/v2.(*Program).Run(0xc00022c400)
        /home/runner/go/pkg/mod/github.com/charmbracelet/bubbletea/v2@v2.0.0-beta.3/tea.go:1022 +0xe76
main.main()
        /home/runner/work/opencode/opencode/packages/tui/cmd/opencode/main.go:106 +0xa98

all of these issues should be resolved in https://github.com/sst/opencode/releases/tag/v0.2.9

can you guys give this a test and lmk?