tempfile icon indicating copy to clipboard operation
tempfile copied to clipboard

ci: test wasi on rust stable

Open Stebalien opened this issue 5 months ago • 4 comments

Stebalien avatar Sep 23 '25 05:09 Stebalien

It appears that we still need the wasip2 feature for:

https://github.com/bytecodealliance/rustix/blob/5245b8160d53a04c37164779cfb11d35e18f55b3/src/path/arg.rs#L350-L388

Otherwise, we can't use rustix's rename with a Path.

Stebalien avatar Sep 23 '25 06:09 Stebalien

I think we can just use https://doc.rust-lang.org/std/ffi/struct.OsStr.html#method.as_encoded_bytes on wasip2, but I'm going to see if I can get upstream rustix to do it.

Stebalien avatar Sep 23 '25 06:09 Stebalien

I realize Path -> str -> Path is not exactly safe but a temporary workaround for wasip2 could be just:

    let old_path_str = old_path.to_str().ok_or(io::Error::new(
        io::ErrorKind::InvalidInput,
        "path not utf-8",
    ))?;
    let new_path_str = new_path.to_str().ok_or(io::Error::new(
        io::ErrorKind::InvalidInput,
        "path not utf-8",
    ))?;

then just pass the Strings instead:

        rename(old_path_str, new_path_str)?;
        let _ = unlink(old_path_str);

xangelix avatar Dec 05 '25 02:12 xangelix

Yep! But the fix has already been merged upstream so I'd rather wait for a release. I'll open an issue there.

Stebalien avatar Dec 05 '25 02:12 Stebalien