From 951b67a6ea66f0aae510d4c82ac768af5af972d5 Mon Sep 17 00:00:00 2001 From: Soc Virnyl Estela Date: Sun, 8 Dec 2024 20:35:47 +0800 Subject: [PATCH] improvement: ensure to communicate well to users when a "No space left on device occurs" The new logic I made is always setting a temporary $CARGO_HOME to ensure fetched packages came from a fresh environment which is deleted after the operation is done. However, I haven't anticipated an issue where a user has a `/tmp` or tmpfs that has a storage space of 1GB. That's too small and not a bug. If there are many bug reports like this, I might consider a solution but since it's user-environment specific, it's a not-a-fix. Signed-off-by: Soc Virnyl Estela --- cargo/src/cli.rs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/cargo/src/cli.rs b/cargo/src/cli.rs index 2d68760..0c9a84f 100644 --- a/cargo/src/cli.rs +++ b/cargo/src/cli.rs @@ -224,7 +224,24 @@ impl Opts { run_cargo_vendor_home_registry(&setup_workdir, &custom_root, self) } Method::Vendor => run_cargo_vendor(&setup_workdir, &custom_root, self), - }?; + }.inspect_err(|err| { + match err.kind() { + io::ErrorKind::StorageFull => { + let dir = std::env::temp_dir(); + error!(?err); + error!( +r#"🛑 Your `$TMPDIR` at {} has less storage space. +Ensure that your `$TMPDIR` at {} has a large storage space than the vendor, registry, and extracted or copied source code. +ℹī¸ A workaround is setting `$TMPDIR` to another directory larger than the total size of your vendored tarball. For example, +``` +export TMPDIR="$HOME/.cache" +osc service -vvv mr cargo_vendor +``` +"#, dir.display(), dir.display()); + } + _ => error!(?err) + } + })?; } else { let mut msg: String = "It seems that the setup workdir is not a directory or does not exist.".to_string();