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

clarify expectations around the workdir concept #5

Open
codefromthecrypt opened this issue Mar 13, 2023 · 2 comments
Open

clarify expectations around the workdir concept #5

codefromthecrypt opened this issue Mar 13, 2023 · 2 comments

Comments

@codefromthecrypt
Copy link

It is increasingly the case that people are conflating WASI with docker, likely due to the increase of tool integrations lately. Folks using docker are used to WORKDIR instructions and CLI overrides such as -workdir.

It isn't clear (to me) why the initial directory cannot be passed to a WASI command, similar to how we are able to pass ENV variables. We should at least document if the next WASI will continue to defer this to wasi-libc with an initial workdir (CWD) of "/", or understand what if any change is likely to occur.

@achille-roussel
Copy link

To add some color, this is how we have currently handled setting up the working directory in the Go WASI implementation https://github.com/Pryz/go/blob/dev-wasi-snapshot-preview1/src/syscall/fs_wasip1.go#L401-L405

	if cwd, _ = Getenv("PWD"); cwd != "" {
		cwd = joinPath("/", cwd)
	} else if len(preopens) > 0 {
		cwd = preopens[0].name
	}

Then we expect the caller of the runtime to set the PWD environment variable, defaulting to the first preopen if it is not set.

@codefromthecrypt
Copy link
Author

also lacking this, tinygo hack wasmtime to mount pre-opens named ".." "../.." etc to let paths resolve relative the working directory https://github.com/tinygo-org/tinygo/blob/9027c50405b13ca48859bc82c660840140621ed5/main.go#L289

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants