Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tinygo build error:package not found #285

Open
LegendBoyWonder opened this issue Jan 15, 2025 · 4 comments
Open

tinygo build error:package not found #285

LegendBoyWonder opened this issue Jan 15, 2025 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@LegendBoyWonder
Copy link

LegendBoyWonder commented Jan 15, 2025

Hi team, I am trying to follow this tutorial:https://component-model.bytecodealliance.org/language-support/go.html#4-build-the-component,
However I failed to build:

~/studyspace/rust/wit-test: tinygo version                                                                             
tinygo version 0.34.0 darwin/arm64 (using go version go1.22.10 and LLVM version 18.1.2)
 ~/studyspace/rust/wit-test : wasm-tools --version
wasm-tools 1.219.1 (91be0bbc8 2024-10-10)
~/studyspace/rust/wit-test : tree .                                                            
.
├── Makefile
├── docs:adder@0.1.0.wasm
├── go.mod
├── go.sum
├── internal
│   ├── docs
│   │   └── adder
│   │       └── adder
│   │           ├── adder.exports.go
│   │           ├── adder.wasm.go
│   │           ├── adder.wit
│   │           ├── adder.wit.go
│   │           └── empty.s
│   └── wasi
│       ├── cli
│       │   ├── environment
│       │   │   ├── empty.s
│       │   │   ├── environment.wasm.go
│       │   │   └── environment.wit.go
│       │   ├── exit
│       │   │   ├── empty.s
│       │   │   ├── exit.wasm.go
│       │   │   └── exit.wit.go
│       │   ├── stderr
│       │   │   ├── empty.s
│       │   │   ├── stderr.wasm.go
│       │   │   └── stderr.wit.go
│       │   ├── stdin
│       │   │   ├── empty.s
│       │   │   ├── stdin.wasm.go
│       │   │   └── stdin.wit.go
│       │   ├── stdout
│       │   │   ├── empty.s
│       │   │   ├── stdout.wasm.go
│       │   │   └── stdout.wit.go
│       │   ├── terminal-input
│       │   │   ├── empty.s
│       │   │   ├── terminal-input.wit.go
│       │   │   └── terminalinput.wasm.go
│       │   ├── terminal-output
│       │   │   ├── empty.s
│       │   │   ├── terminal-output.wit.go
│       │   │   └── terminaloutput.wasm.go
│       │   ├── terminal-stderr
│       │   │   ├── empty.s
│       │   │   ├── terminal-stderr.wit.go
│       │   │   └── terminalstderr.wasm.go
│       │   ├── terminal-stdin
│       │   │   ├── empty.s
│       │   │   ├── terminal-stdin.wit.go
│       │   │   └── terminalstdin.wasm.go
│       │   └── terminal-stdout
│       │       ├── empty.s
│       │       ├── terminal-stdout.wit.go
│       │       └── terminalstdout.wasm.go
│       ├── clocks
│       │   ├── monotonic-clock
│       │   │   ├── empty.s
│       │   │   ├── monotonic-clock.wit.go
│       │   │   └── monotonicclock.wasm.go
│       │   └── wall-clock
│       │       ├── empty.s
│       │       ├── wall-clock.wit.go
│       │       └── wallclock.wasm.go
│       ├── filesystem
│       │   ├── preopens
│       │   │   ├── empty.s
│       │   │   ├── preopens.wasm.go
│       │   │   └── preopens.wit.go
│       │   └── types
│       │       ├── abi.go
│       │       ├── empty.s
│       │       ├── types.wasm.go
│       │       └── types.wit.go
│       ├── io
│       │   ├── error
│       │   │   ├── empty.s
│       │   │   ├── error.wit.go
│       │   │   └── ioerror.wasm.go
│       │   ├── poll
│       │   │   ├── empty.s
│       │   │   ├── poll.wasm.go
│       │   │   └── poll.wit.go
│       │   └── streams
│       │       ├── empty.s
│       │       ├── streams.wasm.go
│       │       └── streams.wit.go
│       ├── random
│       │   ├── insecure
│       │   │   ├── empty.s
│       │   │   ├── insecure.wasm.go
│       │   │   └── insecure.wit.go
│       │   ├── insecure-seed
│       │   │   ├── empty.s
│       │   │   ├── insecure-seed.wit.go
│       │   │   └── insecureseed.wasm.go
│       │   └── random
│       │       ├── empty.s
│       │       ├── random.wasm.go
│       │       └── random.wit.go
│       └── sockets
│           ├── instance-network
│           │   ├── empty.s
│           │   ├── instance-network.wit.go
│           │   └── instancenetwork.wasm.go
│           ├── ip-name-lookup
│           │   ├── abi.go
│           │   ├── empty.s
│           │   ├── ip-name-lookup.wit.go
│           │   └── ipnamelookup.wasm.go
│           ├── network
│           │   ├── abi.go
│           │   ├── empty.s
│           │   ├── network.wasm.go
│           │   └── network.wit.go
│           ├── tcp
│           │   ├── abi.go
│           │   ├── empty.s
│           │   ├── tcp.wasm.go
│           │   └── tcp.wit.go
│           ├── tcp-create-socket
│           │   ├── empty.s
│           │   ├── tcp-create-socket.wit.go
│           │   └── tcpcreatesocket.wasm.go
│           ├── udp
│           │   ├── abi.go
│           │   ├── empty.s
│           │   ├── udp.wasm.go
│           │   └── udp.wit.go
│           └── udp-create-socket
│               ├── empty.s
│               ├── udp-create-socket.wit.go
│               └── udpcreatesocket.wasm.go
├── main.go
├── wit
│   ├── add.wit
│   ├── deps
│   │   ├── cli
│   │   │   ├── command.wit
│   │   │   ├── environment.wit
│   │   │   ├── exit.wit
│   │   │   ├── imports.wit
│   │   │   ├── run.wit
│   │   │   ├── stdio.wit
│   │   │   └── terminal.wit
│   │   ├── clocks
│   │   │   ├── monotonic-clock.wit
│   │   │   ├── timezone.wit
│   │   │   ├── wall-clock.wit
│   │   │   └── world.wit
│   │   ├── filesystem
│   │   │   ├── preopens.wit
│   │   │   ├── types.wit
│   │   │   └── world.wit
│   │   ├── io
│   │   │   ├── error.wit
│   │   │   ├── poll.wit
│   │   │   ├── streams.wit
│   │   │   └── world.wit
│   │   ├── random
│   │   │   ├── insecure-seed.wit
│   │   │   ├── insecure.wit
│   │   │   ├── random.wit
│   │   │   └── world.wit
│   │   └── sockets
│   │       ├── instance-network.wit
│   │       ├── ip-name-lookup.wit
│   │       ├── network.wit
│   │       ├── tcp-create-socket.wit
│   │       ├── tcp.wit
│   │       ├── udp-create-socket.wit
│   │       ├── udp.wit
│   │       └── world.wit
│   ├── deps.lock
│   └── deps.toml
├── wkg.lock
 ~/studyspace/rust/wit-test: tinygo build -target=wasip2 -o add.wasm --wit-package wit/add.wit --wit-world adder main.go
error: package not found
     --> wit/add.wit:3:11
      |
    3 |   include wasi:cli/imports@0.2.0;
      |           ^-------
wasm-tools component embed` failed: exit status 1
@ydnar ydnar added the bug Something isn't working label Jan 19, 2025
@ydnar
Copy link
Collaborator

ydnar commented Jan 21, 2025

Hi, can you try this with #287?

@LegendBoyWonder
Copy link
Author

Hi, can you try this with #287?

Yes, I have tried the latest version, but the result is still the same.

Image

@sd2k
Copy link

sd2k commented Feb 24, 2025

I'm encountering this too. I think it's because tinygo uses a fixed version of wasm-tools as per https://github.com/tinygo-org/tinygo/blob/52983794d702af7a00833ae12b0d2e7175e46017/internal/wasm-tools/go.mod#L5. It's been a bit of a journey updating that version in tinygo, but I've ended up with this commit, which fixes this specific issue but introduces a new one due to a new import cycle (mentioned in the commit message).

@sd2k
Copy link

sd2k commented Feb 24, 2025

Huh, OK I think that last comment can more or less be disregarded (although it may be relevant if/when tinygo wants to update their fixed version of wasm-bindgen-go).

Instead, I managed to get this working by using tinygo build -target=wasip2 -o add.wasm -wit-package wit -wit-world adder main.go instead (note -wit-package wit instead of -wit-package wit/add.wit).

@ydnar ydnar self-assigned this Mar 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants