charmbracelet / gum

A tool for glamorous shell scripts 🎀
MIT License
17.37k stars 331 forks source link

Gum choose "undefined: max" error #581

Closed chrisgilmerproj closed 3 weeks ago

chrisgilmerproj commented 1 month ago

Describe the bug I am trying to install the latest version v0.14.0 of gum using go install.

To Reproduce To reproduce:

GOPATH=/opt/go go install github.com/charmbracelet/gum@latest
# github.com/charmbracelet/gum/choose
go/pkg/mod/github.com/charmbracelet/gum@v0.14.0/choose/command.go:57:11: undefined: max
go/pkg/mod/github.com/charmbracelet/gum@v0.14.0/choose/command.go:58:3: undefined: max

Expected behavior I expected it to install with no issues. Downgrading to v0.13.0 works for me.

Desktop (please complete the following information):

lsb_release -a
LSB Version:    :core-4.1-amd64:core-4.1-noarch
Distributor ID: AlmaLinux
Description:    AlmaLinux release 9.3 (Shamrock Pampas Cat)
Release:    9.3
Codename:   ShamrockPampasCat
MikaelFangel commented 3 weeks ago

Is this issue also present for you with 0.14.1?

chrisgilmerproj commented 3 weeks ago

Here's the error I'm seeing:

go install github.com/charmbracelet/gum@v0.14.1
go: downloading github.com/charmbracelet/gum v0.14.1
go: downloading github.com/alecthomas/kong v0.9.0
go: downloading github.com/charmbracelet/log v0.4.0
go: downloading github.com/charmbracelet/huh v0.4.2
go: downloading github.com/charmbracelet/lipgloss v0.11.0
go: downloading github.com/charmbracelet/bubbles v0.18.0
go: downloading github.com/charmbracelet/bubbletea v0.26.3
go: downloading github.com/charmbracelet/glamour v0.7.0
go: downloading github.com/sahilm/fuzzy v0.1.1
go: downloading golang.org/x/sys v0.20.0
go: downloading github.com/charmbracelet/x/ansi v0.1.1
go: downloading github.com/rivo/uniseg v0.4.7
go: downloading github.com/charmbracelet/x/term v0.1.1
go: downloading golang.org/x/sync v0.7.0
go: downloading github.com/charmbracelet/x/input v0.1.1
go: downloading github.com/catppuccin/go v0.2.0
go: downloading github.com/charmbracelet/x/exp/strings v0.0.0-20240525152034-77596eb8760e
go: downloading golang.org/x/exp v0.0.0-20240525044651-4c93da0ed11d
go: downloading github.com/yuin/goldmark v1.7.1
go: downloading github.com/yuin/goldmark-emoji v1.0.2
go: downloading github.com/alecthomas/chroma/v2 v2.14.0
go: downloading github.com/microcosm-cc/bluemonday v1.0.26
go: downloading github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f
go: downloading github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e
go: downloading golang.org/x/net v0.25.0
go: downloading github.com/gorilla/css v1.0.1
go: downloading github.com/dlclark/regexp2 v1.11.0
# github.com/charmbracelet/gum/choose
/opt/go/pkg/mod/github.com/charmbracelet/gum@v0.14.1/choose/command.go:59:11: undefined: max
/opt/go/pkg/mod/github.com/charmbracelet/gum@v0.14.1/choose/command.go:60:3: undefined: max
note: module requires Go 1.21

The code is here: https://github.com/charmbracelet/gum/blob/main/choose/command.go#L59-L61

Would the problem be that the choose package just doesn't have max() defined like it is in filter ? https://github.com/charmbracelet/gum/blob/main/filter/filter.go#L336-L341

MikaelFangel commented 3 weeks ago

Thank you for trying it out. I can see that go added a built-in function for min() and max() in 1.21 which is also stated as the required version in the output you just send. So which version of go are you using when you try to install? 😊

And to answer your question; it wouldn't make much sense to define it as in filter since the function is now a built-in.

chrisgilmerproj commented 3 weeks ago

That explains it! I am generally using 1.22.X on my machines. But for some reason the version on the machine I'm trying to set up for my coworker is using 1.20.12:

$ go version
go version go1.20.12 linux/amd64

I can't believe I missed the requirement at the bottom of that output. I'll see what I can do about updating my coworker's machine to have a newer version and you can feel free to close this out.

MikaelFangel commented 3 weeks ago

I can't close issues because I'm only a contributor (:

chrisgilmerproj commented 3 weeks ago

I will close it! Thanks for your help though.