-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
(Platform: WSL 2) "error: No such file or directory (os error 2)" during cargo publish #8439
Comments
Thanks for the report! I think we may have merged some improvements to the error message in more recent versions of Cargo, can you try publication with nightly Cargo and see if the error message changes? |
Hey @alexcrichton , thanks for the response. I've done chillup $ cargo -V
cargo 1.46.0-nightly (c26576f9a 2020-06-23)
chillup $ cargo publish -vvv --no-verify
Updating crates.io index
Packaging chillup v0.3.0 (/mnt/c/Users/Cokem/workspace/chillup)
Archiving .cargo_vcs_info.json
Archiving .gitignore
Archiving Cargo.lock
Archiving Cargo.toml
Archiving Cargo.toml.orig
Archiving README.md
Archiving src/main.rs
Uploading chillup v0.3.0 (/mnt/c/Users/Cokem/workspace/chillup)
error: No such file or directory (os error 2) Is this in-line with your expectations? |
@alexcrichton do you have access to a Windows machine with WSL2? For some reason, mine won't let me upgrade. I tried publishing in WSL1, and it seemed fine. However, AIUI, WSL2 has completely redone how the filesystem mounting works, and I would be suspicious if something related to that is an issue. |
I do have a Windows machine but apparently it won't let me update to the latest Windows to get WSL2. I'm not entirely sure why (it just points me here and says "no action needed", but I can try this in the future if it lets me update. |
Hey @alexcrichton, I had the same experience. The easiest way to force the upgrade is to join the windows insider program on one of the release rings. To be honest, I don't recommend doing it. Microsoft forces you to enable telemetry to join insider ring. The only reason I've done this is to get access to docker wsl backend. I would be happy to gather more diagnostics, or if someone does want to force this upgrade, happy to provide help with that. I'm Cheers, |
You can force update with Update Assistant: https://www.microsoft.com/en-gb/software-download/windows10 I believe this fails in WSL2 because you are in fact using "remote" directory. Unlike WSL, WSL2 is a virtual machine so it cannot directly access host directories. To workaround that Windows partitions are available as |
@mati865 thanks for the insights. I've managed to publish from a directory in Leaving this issue open as cargo should provide better diags when this happens (and fix the bug itself). For next steps it's probably needed to isolate what area of code breaks down. I can easily reproduce this, and I'm happy to help. Cheers, |
I bumped into this same issue yesterday and I did some digging. I traced the problem to the point where the diff --git i/crates/crates-io/lib.rs w/crates/crates-io/lib.rs
index 3b8b30b30..2561b27c9 100644
--- i/crates/crates-io/lib.rs
+++ w/crates/crates-io/lib.rs
@@ -169,7 +169,14 @@ impl Registry {
// <json request> (metadata for the package)
// <le u32 of tarball>
// <source tarball>
- let stat = tarball.metadata()?;
+ let stat = match tarball.metadata() {
+ Ok(stat) => stat,
+ Err(err) => bail!(
+ "failed to read tarball metadata for file {:?}: {}",
+ tarball,
+ err
+ ),
+ };
let header = {
let mut w = Vec::new();
w.extend(&(json.len() as u32).to_le_bytes());
(END) Applying that diff, I get the following output:
The supposed missing file can be read correctly otherwise:
|
Hey all, it seems this bug showed up again. Happy to start another issue for this if we want since I believe it's a different part of the code, just same symptoms.
Relevant strace:
It looks like it was reintroduced late last month, in commit 81f0f63. I figure this could be solved most easily by:
Happy to submit a PR with one of those solutions, it may just take me a bit to get a cargo dev environment setup. I agree with @mati865's general conclusion that WSL handles 9p files oddly - it seems to lose the ability to stat a file through a file descriptor after renaming it (see strace above). I've wrote a small test for it below, along with the output for my system.
use std::fs;
#[cfg(unix)]
use std::os::unix::fs::MetadataExt;
fn main() {
// create file
// rename it by path to something else
// get file metadata from original file descriptor
const FILE_SRC: &str = "test_file_src.txt";
const FILE_DST: &str = "test_file_dst.txt";
eprintln!("cwd: {}", std::env::current_dir().unwrap().display());
let f = fs::File::create(FILE_SRC).expect("error creating original file");
let fm = f.metadata().expect("unable to get new file's metadata");
#[cfg(unix)]
eprintln!("current file's dev/inode before rename: {}/{}", fm.dev(), fm.ino());
fs::rename(FILE_SRC, FILE_DST).expect("error renaming file");
#[cfg(unix)] {
eprintln!("current file's dev/inode after rename: {}/{}", fm.dev(), fm.ino());
match fs::File::open(FILE_DST) {
Ok(fr) => {
// seems to be allowed on ext4, not p9
let fr = fr.metadata().expect("unable to fetch metadata for newly renamed file");
eprintln!("renamed file's dev/inode: {}/{}", fr.dev(), fr.ino());
},
Err(e) => {
eprintln!("renamed file's dev/inode: (failed: {:?})", e);
}
}
}
eprintln!("Result: able to get renamed file's metadata from original FD/Handle: {:?}", f.metadata().is_ok());
} My system versions + test output
|
tl;dr appears related to WSL NTFS mounts, workaround is Bug ObservationUsing Ubuntu 22 on WSL2, I attempted to
The
I tried This appears related to NTFS mounts used by WSL2 Linux. A week ago using the same project path Workaround
Context
|
Problem
cargo publish
yieldserror: No such file or directory (os error 2)
without any further diagnostics.Steps
Unclear. On my machine:
chillup $ cargo clean chillup $ cargo build && cargo build --release (snip) chillup $ cargo publish -vvv --no-verify Updating crates.io index Packaging chillup v0.3.0 (/mnt/c/Users/Cokem/workspace/chillup) Archiving .cargo_vcs_info.json Archiving .gitignore Archiving Cargo.lock Archiving Cargo.toml Archiving Cargo.toml.orig Archiving README.md Archiving src/main.rs Uploading chillup v0.3.0 (/mnt/c/Users/Cokem/workspace/chillup) error: No such file or directory (os error 2)
Possible Solution(s)
n/a - need better diags
Notes
Output of
cargo version
:cargo 1.44.1 (88ba85757 2020-06-11)
rustc 1.44.1 (c7087fe00 2020-06-17)
wsl -l -v NAME STATE VERSION * Ubuntu Running 2
Note: This package already exists - I expect
publish
to update it.Note: I have successfully published on WSL with this machine already, but this is my first time trying since upgrading to WSL 2.
Note: I generated a new crates.io auth key as a guess for the issue, which did not solve the problem
The text was updated successfully, but these errors were encountered: