Skip to content

os: GOOS=wasip1 returns non-IsNotExist errors on non-existent files #60732

Open
@bradfitz

Description

@bradfitz

I'm trying to run some code with to-be Go 1.21's wasip1/wasm support.

We have some code:

	cfgPath := filepath.Join(s.rootPath, "tailscaled.log.conf")
	lpc, err := logpolicy.ConfigFromFile(cfgPath)
	switch {
	case os.IsNotExist(err):
		lpc = logpolicy.NewConfig(logtail.CollectionNode)
		if err := lpc.Save(cfgPath); err != nil {
			return fmt.Errorf("logpolicy.Config.Save for %v: %w", cfgPath, err)
		}
	case err != nil:
		return fmt.Errorf("logpolicy.LoadConfig for %v: %w", cfgPath, err)
	}

And instead of hitting that os.IsNotExist path, it's going into the case err != nil path with:

$ wasmtime run --env=HOME=$HOME --dir=. ~/go/bin/wasip1_wasm/tshello
2023/06/12 00:28:09 tsnet: logpolicy.LoadConfig for tailscaled.log.conf: open tailscaled.log.conf: Bad file number

It's possible I'm holding wasmtime wrong, but "Bad file number" doesn't tell me much. Is that a not found error or a sandbox violation error, or ...?

/cc @johanbrandhorst

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.arch-wasmWebAssembly issues

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions