From 9e8102b708d12fa5579dc8015d5987fdcbe4d5b5 Mon Sep 17 00:00:00 2001 From: Niels Saurer Date: Wed, 19 Feb 2025 15:01:18 +0100 Subject: [PATCH] make CARGO_HOME optionally read/write --- src/cmd/mod.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs index 189d167..4d7e2b2 100644 --- a/src/cmd/mod.rs +++ b/src/cmd/mod.rs @@ -211,6 +211,7 @@ pub struct Command<'w, 'pl> { no_output_timeout: Option, log_command: bool, log_output: bool, + cargo_home_mount_kind: MountKind, } impl<'w, 'pl> Command<'w, 'pl> { @@ -261,9 +262,16 @@ impl<'w, 'pl> Command<'w, 'pl> { no_output_timeout, log_output: true, log_command: true, + cargo_home_mount_kind: MountKind::ReadOnly, } } + /// Mount the cargo home directory as read-write in the sandbox. + pub fn rw_cargo_home(mut self) -> Self { + self.cargo_home_mount_kind = MountKind::ReadWrite; + self + } + /// Add command-line arguments to the command. This method can be called multiple times to add /// additional args. pub fn args>(mut self, args: &[S]) -> Self { @@ -413,7 +421,7 @@ impl<'w, 'pl> Command<'w, 'pl> { .mount( &workspace.cargo_home(), &container_dirs::CARGO_HOME, - MountKind::ReadOnly, + self.cargo_home_mount_kind, ) .mount( &workspace.rustup_home(),