I have the following test code
func main() {
path, err := os.Getwd()
log.Println(path, err)
files, err := ioutil.ReadDir("/etc/dse")
log.Println(files, err)
}
I compile it to wasm using
tinygo build -target wasi -o list.wasm list.go
Then I executeit using
wasmtime list.wasm
The output is
2023/05/05 16:00:50 / <nil>
2023/05/05 16:00:50 [] open /etc/dse: errno 76
At the same time, the directory /etc/dse exists and has permissions 777.
What is the source of this error and how to fix this?
errno 76meanscapabilities insufficient.You have to give it capabilities to access files in the requisite directories, with the
wasmtimeoption--dir(see wasmtime WASI tutorial):Unfortunately,
readdiris not implemented in TinyGo yet.References: