AlecAivazis / survey

A golang library for building interactive and accessible prompts with full support for windows and posix terminals.
MIT License
4.07k stars 350 forks source link

This library does actually not support all posix systems (please use x/sys/unix instead of syscall package) #434

Open Toasterson opened 1 year ago

Toasterson commented 1 year ago

What operating system and terminal are you using? illumos and bash

An example that showcases the bug. Compile github cli or any project using this library on a system not linux

What did you expect to see? Github cli being able to compile

What did you see instead?

go build -trimpath -ldflags "-X github.com/cli/cli/v2/internal/build.Date=2022-07-11 -X github.com/cli/cli/v2/internal/build.Version=v2.13.0-19-g604adc57 " -o bin/gh ./cmd/gh
# github.com/AlecAivazis/survey/v2/terminal
../go/pkg/mod/github.com/!alec!aivazis/survey/v2@v2.3.5/terminal/runereader_posix.go:47:43: undefined: syscall.SYS_IOCTL
../go/pkg/mod/github.com/!alec!aivazis/survey/v2@v2.3.5/terminal/runereader_posix.go:47:81: undefined: ioctlReadTermios
../go/pkg/mod/github.com/!alec!aivazis/survey/v2@v2.3.5/terminal/runereader_posix.go:59:43: undefined: syscall.SYS_IOCTL
../go/pkg/mod/github.com/!alec!aivazis/survey/v2@v2.3.5/terminal/runereader_posix.go:59:81: undefined: ioctlWriteTermios
../go/pkg/mod/github.com/!alec!aivazis/survey/v2@v2.3.5/terminal/runereader_posix.go:67:43: undefined: syscall.SYS_IOCTL
../go/pkg/mod/github.com/!alec!aivazis/survey/v2@v2.3.5/terminal/runereader_posix.go:67:81: undefined: ioctlWriteTermios

Background the syscall package does not support all posix systems properly as it has been last updated sometime in 2015. Back then only linux was decently well supported for IOCTL's and other calls. Since then all further improvements have gone into x/sys/unix and not into syscall.

mislav commented 1 year ago

Thank you for reporting! Agreed that this library should avoid dropping down to syscall and instead use more of the standard library to avoid cross-platform limitations. I've tried a migration here but it broke some prompts https://github.com/AlecAivazis/survey/pull/377

Toasterson commented 1 year ago

x/sys/unix is a drop in replacement for syscall infact it's the same package. The problem is not dropping down to the sycall layer, it is using an extremely out of date and limited version of that package.

Toasterson commented 1 year ago

Also important for #385 #372