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

__WASI_ENOENT when renaming a file #3084

Closed
dicej opened this issue Aug 9, 2022 · 2 comments · Fixed by #3088
Closed

__WASI_ENOENT when renaming a file #3084

dicej opened this issue Aug 9, 2022 · 2 comments · Fixed by #3088
Assignees
Labels
bug Something isn't working
Milestone

Comments

@dicej
Copy link

dicej commented Aug 9, 2022

Describe the bug

While working on konsoletyper/teavm#610, I noticed that renaming a file in a preopened directory doesn't seem to work in Wasmer. I originally noticed this when testing a Java program, but was able to reproduce it in Rust.

echo "`wasmer -V` | `rustc -V` | `uname -m`"

Wasmer complains that it doesn't understand the -V flag, but I'm using wasmer-cli built from commit 22c3736, which was master as of yesterday.

 | rustc 1.62.0 (a8314ef7d 2022-06-27) | x86_64

Steps to reproduce

  1. Build the following Rust program using cargo build --target wasm32-wasi:
fn main() -> Result<(), Box<dyn std::error::Error>> {
    std::fs::rename("foo/bar.txt", "foo/um.txt")?;
    Ok(())
}
  1. Create the directory and add the file to it:
mkdir foo
touch foo/bar.txt
  1. Run the program:
wasmer --dir foo target/wasm32-wasi/debug/wasi-file-test.wasm

Expected behavior

The foo/bar.txt file would be renamed to foo/um.txt. This is the behavior when running the module using Wasmtime.

Actual behavior

Error: Os { code: 44, kind: NotFound, message: "No such file or directory" }

@dicej dicej added the bug Something isn't working label Aug 9, 2022
@syrusakbary
Copy link
Member

Thanks for opening the issue @dicej! We'll take a look

@syrusakbary syrusakbary added this to the v3.0 milestone Aug 9, 2022
@ptitSeb
Copy link
Contributor

ptitSeb commented Aug 9, 2022

I reproduce the issue with current master. I'll check what's going on.

bors bot added a commit that referenced this issue Aug 10, 2022
3088: Fixed an issue when renaming a file from a preopened dir directly (for 3084) r=ptitSeb a=ptitSeb

# Description
Fixed an issue that could happens when renaming a file from a reopened folder
Fix #3084 

Co-authored-by: ptitSeb <[email protected]>
@bors bors bot closed this as completed in b3c3df0 Aug 10, 2022
ptitSeb added a commit that referenced this issue Aug 11, 2022
bors bot added a commit that referenced this issue Aug 11, 2022
3093: Fixed a potential issue when renaming a file r=ptitSeb a=ptitSeb

Fixed a potential issue when renaming a file and the destination is from a preopened dir and already exist (for #3084)


Co-authored-by: ptitSeb <[email protected]>
ptitSeb added a commit that referenced this issue Oct 20, 2022
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

Successfully merging a pull request may close this issue.

3 participants