Closed
Description
Problem
On Rust 1.34.1, as long as all the dependencies were pre-fetched with cargo fetch
, running cargo check --frozen
never touched the ~/.cargo
directory, allowing it to be read-only. This behavior is used by Crater to prevent misbehaving crates from messing up the cargo installation.
The latest nightly instead requires that directory to be writable:
error: failed to acquire package cache lock
Caused by:
failed to open: /home/pietro/tmp/repro/tmp-cargo-home/.package-cache
Caused by:
Permission denied (os error 13)
Steps
#!/bin/bash
set +euo pipefail
if [[ $# -ne 1 ]]; then
echo "usage: $0 <toolchain-name>"
exit 1
fi
export RUSTUP_TOOLCHAIN="$1"
# Use a temporary cargo home so the user-wide one is not messed up
export CARGO_HOME=tmp-cargo-home
set -x
# Create a simple repro crate which depends on lazy_static
cargo init --bin repro
cd repro
echo 'lazy_static = "1"' >> Cargo.toml
# Generate the lockfile and fetch the dependencies using it
cargo generate-lockfile
cargo fetch --locked
# Make the cargo home read-only
chmod -w -R "${CARGO_HOME}"
cargo check --frozen
bash repro.sh stable
for the correct behaviorbash repro.sh nightly
for the wrong behavior
Possible Solution(s)
After talking to @Eh2406 the issue seems to be caused by #6880.