Open
Description
Encountered an error while attempted to compile the embedded version of Starlet to Webassembly:
# github.com/chzyer/readline
/go/pkg/mod/github.com/chzyer/[email protected]/utils.go:81:29: undefined: State
/go/pkg/mod/github.com/chzyer/[email protected]/utils.go:241:9: undefined: State
/go/pkg/mod/github.com/chzyer/[email protected]/operation.go:234:4: undefined: ClearScreen
/go/pkg/mod/github.com/chzyer/[email protected]/readline.go:129:20: undefined: GetScreenWidth
/go/pkg/mod/github.com/chzyer/[email protected]/readline.go:132:22: undefined: DefaultIsTerminal
/go/pkg/mod/github.com/chzyer/[email protected]/readline.go:142:26: undefined: DefaultOnWidthChanged
/go/pkg/mod/github.com/chzyer/[email protected]/remote.go:324:2: undefined: DefaultOnWidthChanged
/go/pkg/mod/github.com/chzyer/[email protected]/remote.go:346:17: undefined: GetScreenWidth
/go/pkg/mod/github.com/chzyer/[email protected]/remote.go:362:16: undefined: DefaultIsTerminal
/go/pkg/mod/github.com/chzyer/[email protected]/terminal.go:51:2: undefined: SuspendMe
/go/pkg/mod/github.com/chzyer/[email protected]/terminal.go:51:2: too many errors
- Go version: 1.24.0, but the same error in older compiler versions too.
- Starlet version: latest published, v0.1.2
- chzyer/readline versions: both latest, v1.5.1 and
v0.0.0-20180603132655-2972be24d48e
used in Starlet.
Reproduction steps
mkdir reproduce-error
cd reproduce-error
go mod init main
go get github.com/1set/starlet
cat > starlet.go << 'END'
package main
import (
"github.com/1set/starlet"
)
func main() {
const code = `
print('Hello from Starlet!')
`
machine := starlet.NewWithBuiltins(nil, nil, nil)
_, err := machine.RunScript([]byte(code), nil)
if err != nil {
panic(err)
}
}
END
# works OK in console
go run starlet.go
# fails to compile to WASM
GOOS=js GOARCH=wasm go build -o starlet.wasm starlet.go
Same error against latest available version of chzyer/readline, 1.5.1 at the this time
Error:
# github.com/chzyer/readline
/go/pkg/mod/github.com/chzyer/[email protected]/utils.go:84:29: undefined: State
/go/pkg/mod/github.com/chzyer/[email protected]/utils.go:265:9: undefined: State
/go/pkg/mod/github.com/chzyer/[email protected]/operation.go:236:4: undefined: ClearScreen
/go/pkg/mod/github.com/chzyer/[email protected]/readline.go:131:20: undefined: GetScreenWidth
/go/pkg/mod/github.com/chzyer/[email protected]/readline.go:134:22: undefined: DefaultIsTerminal
/go/pkg/mod/github.com/chzyer/[email protected]/readline.go:144:26: undefined: DefaultOnWidthChanged
/go/pkg/mod/github.com/chzyer/[email protected]/remote.go:324:2: undefined: DefaultOnWidthChanged
/go/pkg/mod/github.com/chzyer/[email protected]/remote.go:346:17: undefined: GetScreenWidth
/go/pkg/mod/github.com/chzyer/[email protected]/remote.go:362:16: undefined: DefaultIsTerminal
/go/pkg/mod/github.com/chzyer/[email protected]/terminal.go:51:2: undefined: SuspendMe
/go/pkg/mod/github.com/chzyer/[email protected]/terminal.go:51:2: too many errors
Reproduction steps
mkdir reproduce-error-v1.5.1
cd reproduce-error-v1.5.1
go mod init main
go get github.com/1set/starlet
go get github.com/chzyer/[email protected]
cat > starlet.go << 'END'
package main
import (
"github.com/1set/starlet"
)
func main() {
const code = `
print('Hello from Starlet!')
`
machine := starlet.NewWithBuiltins(nil, nil, nil)
_, err := machine.RunScript([]byte(code), nil)
if err != nil {
panic(err)
}
}
END
# works OK in console
go run starlet.go
# fails to compile to WASM
GOOS=js GOARCH=wasm go build -o starlet.wasm starlet.go
Why reporting to Starlet repo
- It appears the chzyer/readline is not actively maintained at this time.
- Starlet depends on fixed (and old) version of chzyer/readline.
Possible solutions on Starlet side
Have not analyzed the code of Starlet very deeply, but AFAICU one of the following fixes is possible:
- Move readline-related functionality to
CLI
, decoupling the core suitable for embedding from IO dependencies. - Implement a conditional compilation to exclude readline-related code on selected platforms.
What do you think?
BTW thank you all for your work on Starlet!
Metadata
Assignees
Labels
No labels
Activity