Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

wizer.initialize can't read file even if --allow-wasi --dir . specified?

未关闭
#24 6 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
rust, wasm
领域
cli, devtools

调研方向

使用 main.go、main.wasm、test.txt 以及带有 --allow-wasi --dir . 的 wizer 命令重现该失败,然后将其与成功的 wasmtime --dir . 运行进行比较。跟踪 wizer 在 wizer.initialize 入口点期间如何处理 --dir preopen;当初始化函数能够读取 test.txt 并在没有 errno 76 错误的情况下生成 out.wasm 时,即表示完成。

由索引模型根据 Issue 内容生成。

描述

Given the program

package main
import  "os"
var theText string
//go:export wizer.initialize
func WizerInitialize() {
        buf, err := os.ReadFile("test.txt")
        if err != nil {
                println("error: Cannot read test.txt", err.Error())
        }
        theText = string(buf)
}
func main() {
        if theText == "" {
                WizerInitialize()
        }
        println("theText", theText)
}

This succeeds, and outputs foobar as expected:

tinygo build -target=wasi -scheduler=none -wasm-abi=generic -o main.wasm main.go
echo "foobar" > test.txt
wasmtime --dir . main.wasm

but this

wizer --allow-wasi --dir . -o out.wasm < main.wasm

fails with

error: Cannot read test.txt open test.txt: errno 76

Setting RUST_LOG=debug shows that it is at least preopening the directory:

[2021-07-20T16:12:44Z DEBUG wizer] Validating input Wasm
[2021-07-20T16:12:44Z DEBUG wizer] Preparing input Wasm
[2021-07-20T16:12:44Z DEBUG wasmtime_cache::worker] Cache worker thread started.
[2021-07-20T16:12:44Z DEBUG wasmtime_cache::worker] New nice value of worker thread: 3
[2021-07-20T16:12:44Z DEBUG wizer] Validating the exported initialization function
[2021-07-20T16:12:44Z DEBUG wizer] Calling the initialization function
[2021-07-20T16:12:44Z DEBUG wizer] Preopening directory: .
[2021-07-20T16:12:44Z DEBUG wizer] Creating dummy imports
error: Cannot read test.txt open test.txt: errno 76

Passing a bad directory to --dir does abort, so it is at least opening the directory.

This is on mac, so I have not gone through the agony of using dtruss to see if it is actually trying to open a file.

主要语言
Rust
星标
1.1k
派生
64
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

bytecodealliance/wizer 的其他 Issue

查看 bytecodealliance/wizer 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。