Skip to content

Commit 5753165

Browse files
astrosbourdeauducq
andauthored
Ensure copied Cargo.lock is writable (#98)
> If the path pointed to by XARGO_RUST_SRC contains read-only Cargo > lockfiles, then xbuild fails because the copies it makes and attempts to > modify are also read-only. Co-authored-by: Sebastien Bourdeauducq <[email protected]>
1 parent 6d17939 commit 5753165

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

src/sysroot.rs

+16-2
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,25 @@ fn build_crate(
8585
}
8686

8787
util::write(&td.join("Cargo.toml"), &stoml)?;
88-
fs::copy(lockfile, &td.join("Cargo.lock")).with_context(|| {
88+
let td_lockfile = &td.join("Cargo.lock");
89+
fs::copy(lockfile, td_lockfile).with_context(|| {
8990
format!(
9091
"failed to copy Cargo.lock from `{}` to `{}`",
9192
lockfile.display(),
92-
&td.join("Cargo.lock").display()
93+
td_lockfile.display()
94+
)
95+
})?;
96+
let mut perms = fs::metadata(&td_lockfile).with_context(|| {
97+
format!(
98+
"failed to retrieve permissions for `{}`",
99+
td_lockfile.display()
100+
)
101+
})?.permissions();
102+
perms.set_readonly(false);
103+
fs::set_permissions(&td_lockfile, perms).with_context(|| {
104+
format!(
105+
"failed to set writable permission for `{}`",
106+
td_lockfile.display()
93107
)
94108
})?;
95109
util::mkdir(&td.join("src"))?;

0 commit comments

Comments
 (0)