Encountered an error while attempted to compile the embedded version of Starlet to Webassembly:
# github.com/chzyer/readline
/go/pkg/mod/github.com/chzyer/readline@v0.0.0-20180603132655-2972be24d48e/utils.go:81:29: undefined: State
/go/pkg/mod/github.com/chzyer/readline@v0.0.0-20180603132655-2972be24d48e/utils.go:241:9: undefined: State
/go/pkg/mod/github.com/chzyer/readline@v0.0.0-20180603132655-2972be24d48e/operation.go:234:4: undefined: ClearScreen
/go/pkg/mod/github.com/chzyer/readline@v0.0.0-20180603132655-2972be24d48e/readline.go:129:20: undefined: GetScreenWidth
/go/pkg/mod/github.com/chzyer/readline@v0.0.0-20180603132655-2972be24d48e/readline.go:132:22: undefined: DefaultIsTerminal
/go/pkg/mod/github.com/chzyer/readline@v0.0.0-20180603132655-2972be24d48e/readline.go:142:26: undefined: DefaultOnWidthChanged
/go/pkg/mod/github.com/chzyer/readline@v0.0.0-20180603132655-2972be24d48e/remote.go:324:2: undefined: DefaultOnWidthChanged
/go/pkg/mod/github.com/chzyer/readline@v0.0.0-20180603132655-2972be24d48e/remote.go:346:17: undefined: GetScreenWidth
/go/pkg/mod/github.com/chzyer/readline@v0.0.0-20180603132655-2972be24d48e/remote.go:362:16: undefined: DefaultIsTerminal
/go/pkg/mod/github.com/chzyer/readline@v0.0.0-20180603132655-2972be24d48e/terminal.go:51:2: undefined: SuspendMe
/go/pkg/mod/github.com/chzyer/readline@v0.0.0-20180603132655-2972be24d48e/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
readline versions available
Error:
# github.com/chzyer/readline
/go/pkg/mod/github.com/chzyer/readline@v1.5.1/utils.go:84:29: undefined: State
/go/pkg/mod/github.com/chzyer/readline@v1.5.1/utils.go:265:9: undefined: State
/go/pkg/mod/github.com/chzyer/readline@v1.5.1/operation.go:236:4: undefined: ClearScreen
/go/pkg/mod/github.com/chzyer/readline@v1.5.1/readline.go:131:20: undefined: GetScreenWidth
/go/pkg/mod/github.com/chzyer/readline@v1.5.1/readline.go:134:22: undefined: DefaultIsTerminal
/go/pkg/mod/github.com/chzyer/readline@v1.5.1/readline.go:144:26: undefined: DefaultOnWidthChanged
/go/pkg/mod/github.com/chzyer/readline@v1.5.1/remote.go:324:2: undefined: DefaultOnWidthChanged
/go/pkg/mod/github.com/chzyer/readline@v1.5.1/remote.go:346:17: undefined: GetScreenWidth
/go/pkg/mod/github.com/chzyer/readline@v1.5.1/remote.go:362:16: undefined: DefaultIsTerminal
/go/pkg/mod/github.com/chzyer/readline@v1.5.1/terminal.go:51:2: undefined: SuspendMe
/go/pkg/mod/github.com/chzyer/readline@v1.5.1/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/readline@v1.5.1
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!
Encountered an error while attempted to compile the embedded version of Starlet to Webassembly:
v0.0.0-20180603132655-2972be24d48eused in Starlet.Reproduction steps
Same error against latest available version of chzyer/readline, 1.5.1 at the this time
readline versions available
Error:
Reproduction steps
Why reporting to Starlet repo
Possible solutions on Starlet side
Have not analyzed the code of Starlet very deeply, but AFAICU one of the following fixes is possible:
CLI, decoupling the core suitable for embedding from IO dependencies.What do you think?
BTW thank you all for your work on Starlet!