I'm working with a GitHub Actions pipeline where the runners are offline, as the environment is restricted. I've already installed Rust and Cargo in the container, but when trying to run Cargo commands (such as cargo clean or cargo doc), I encounter an error:
error: could not download file from '.78.0.toml.sha256'
The goal is to run Cargo commands in this offline environment, but it seems like Cargo is attempting to fetch files from the internet, which isn't possible in this case.
Here is the GitHub Actions step I’m running:
name: Check Cargo path and run cargo clean
run: |
docker run --rm -v $GITHUB_WORKSPACE:/workspace --workdir /workspace --entrypoint sh $container_cargo -c '
set -e
export CARGO_HOME=/root/.cargo;
export RUSTUP_HOME=/root/.rustup;
export PATH=$CARGO_HOME/bin:$PATH;
export SOURCE_BRANCH=${{ github.ref_name }};
echo 'Verifying rustup installation'
rustup --version
rustup target list --installed
echo "Listing files in the current directory:";
ls -l; # List files in the current directory to verify Cargo.toml
if command -v cargo &> /dev/null; then
cargo --version && echo "Cargo found!";
echo "Running cargo clean...";
cargo clean;
echo "Generating documentation with cargo doc...";
cargo doc --no-deps;
else
echo "Cargo not found.";
fi
'
docker run --rm $container_cargo cargo clean
env:
container_cargo:latest