rust-corpus / qrates

A framework for large scale analysis of the Rust ecosystem.
MIT License
38 stars 9 forks source link

failed to get dependency of package when compile #219

Closed wyf18 closed 2 years ago

wyf18 commented 2 years ago

my CrateList.json

{
  "creation_date": {
    "secs_since_epoch": 1579271281,
    "nanos_since_epoch": 847419904
  },
  "crates": [
    {
      "Package": {
        "name": "rand",
        "version": "0.8.4"
      }
    }
  ]
}

which is the latest version of crate rand. When I run

sudo env "PATH=$PATH" $(which cargo) run --release -- compile

I found it can't compile

[INFO] running `Command { std: "docker" "create" "-v" "/home/wuyf/doc_test/workspace/builds/corpus/target:/opt/rustwide/target:rw,Z" "-v" "/home/wuyf/doc_test/workspace/builds/corpus/source:/opt/rustwide/workdir:ro,Z" "-v" "/home/wuyf/doc_test/workspace/cargo-home:/opt/rustwide/cargo-home:ro,Z" "-v" "/home/wuyf/doc_test/workspace/rustup-home:/opt/rustwide/rustup-home:ro,Z" "-e" "SOURCE_DIR=/opt/rustwide/workdir" "-e" "CARGO_TARGET_DIR=/opt/rustwide/target" "-e" "RUST_BACKTRACE=1" "-e" "SYSROOT=/opt/rustwide/cargo-home/sysroot" "-e" "RUSTC=/opt/rustwide/cargo-home/rustc" "-e" "CARGO_HOME=/opt/rustwide/cargo-home" "-e" "RUSTUP_HOME=/opt/rustwide/rustup-home" "-w" "/opt/rustwide/workdir" "-m" "4000000000" "--user" "0:0" "--network" "none" "rustops/crates-build-env@sha256:c46a2d1a26fb48b37929c74ca49dd9409f2375a0a3bdb8fe07617f3ffccaa889" "/opt/rustwide/cargo-home/bin/cargo" "+nightly-2022-04-15" "check" "--all", kill_on_drop: false }`
[INFO] [stdout] cbfa4893d86c61285081af65143c89766efb528d046a169d9ff69415b0a6a7e1
[INFO] [stderr] WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
[INFO] running `Command { std: "docker" "start" "-a" "cbfa4893d86c61285081af65143c89766efb528d046a169d9ff69415b0a6a7e1", kill_on_drop: false }`
[INFO] [stderr] error: failed to get `log` as a dependency of package `rand v0.8.4 (/opt/rustwide/workdir)`
[INFO] [stderr] 
[INFO] [stderr] Caused by:
[INFO] [stderr]   failed to create directory `/opt/rustwide/cargo-home/registry/index/github.com-1ecc6299db9ec823`
[INFO] [stderr] 
[INFO] [stderr] Caused by:
[INFO] [stderr]   Read-only file system (os error 30)
[INFO] running `Command { std: "docker" "inspect" "cbfa4893d86c61285081af65143c89766efb528d046a169d9ff69415b0a6a7e1", kill_on_drop: false }`
[INFO] running `Command { std: "docker" "rm" "-f" "cbfa4893d86c61285081af65143c89766efb528d046a169d9ff69415b0a6a7e1", kill_on_drop: false }`
[INFO] [stdout] cbfa4893d86c61285081af65143c89766efb528d046a169d9ff69415b0a6a7e1

Is it my network problem that makes it failed to get dependencies?

vakaras commented 2 years ago

The log says that the error is caused by the file system being read-only:

[INFO] [stderr] Caused by:
[INFO] [stderr]   Read-only file system (os error 30)

And in the log you can also see that /opt/rustwide/cargo-home/registry/index/github.com-1ecc6299db9ec823 is mounted as readonly: "-v" "/home/wuyf/doc_test/workspace/cargo-home:/opt/rustwide/cargo-home:ro,Z". However, it is unclear to me why it is trying to write to that directory.

vakaras commented 2 years ago

I tried to update the dependencies. Maybe that helps. Could you please try compiling again once this PR gets merged?

wyf18 commented 2 years ago

I tried to update the dependencies. Maybe that helps. Could you please try compiling again once this PR gets merged?

Unfortunately, it doesn't work, same error. :( by the way, I find a issue of rustwide, I've no idea how to solve it.

vakaras commented 2 years ago

I cannot reproduce the problem and I am not sure how to debug it. Could you please upload the entire log? Maybe, it will help me to spot what is going wrong.

wyf18 commented 2 years ago

I deleted the rand-0.7.3 directory and try

wuyf@cssustc:~/doc_test/qrates$ sudo env "PATH=$PATH" $(which cargo) run --release -- compile
    Finished release [optimized] target(s) in 0.11s
     Running `target/release/corpus-manager-driver compile`
09:40:12 [INFO] The standard library is already built.
09:40:12 [INFO] pulling image ghcr.io/rust-lang/crates-build-env/linux from Docker Hub
09:40:12 [INFO] running `Command { std: "docker" "pull" "ghcr.io/rust-lang/crates-build-env/linux", kill_on_drop: false }`
09:40:12 [INFO] [stdout] Using default tag: latest
09:40:14 [INFO] [stdout] latest: Pulling from rust-lang/crates-build-env/linux
09:40:14 [INFO] [stdout] Digest: sha256:b0c94ce3c1162fcb8e57cac5b65ec2f72eabb1eebea4fcc35e269e823f681646
09:40:14 [INFO] [stdout] Status: Image is up to date for ghcr.io/rust-lang/crates-build-env/linux:latest
09:40:14 [INFO] [stdout] ghcr.io/rust-lang/crates-build-env/linux:latest
09:40:14 [INFO] running `Command { std: "docker" "inspect" "ghcr.io/rust-lang/crates-build-env/linux" "--format" "{{index .RepoDigests 0}}", kill_on_drop: false }`
09:40:14 [INFO] pulled image ghcr.io/rust-lang/crates-build-env/linux@sha256:b0c94ce3c1162fcb8e57cac5b65ec2f72eabb1eebea4fcc35e269e823f681646
09:40:14 [INFO] checking the image ghcr.io/rust-lang/crates-build-env/linux@sha256:b0c94ce3c1162fcb8e57cac5b65ec2f72eabb1eebea4fcc35e269e823f681646 is available locally
09:40:14 [INFO] running `Command { std: "docker" "image" "inspect" "ghcr.io/rust-lang/crates-build-env/linux@sha256:b0c94ce3c1162fcb8e57cac5b65ec2f72eabb1eebea4fcc35e269e823f681646", kill_on_drop: false }`
09:40:14 [INFO] installing tools required by rustwide
09:40:14 [INFO] tool rustup is installed, trying to update it
09:40:14 [INFO] running `Command { std: "/home/wuyf/doc_test/workspace/cargo-home/bin/rustup" "self" "update", kill_on_drop: false }`
09:40:14 [INFO] [stderr] info: checking for self-updates
09:40:14 [INFO] [stdout]   rustup unchanged - 1.24.3
09:40:14 [INFO] [stdout]
09:40:14 [INFO] running `Command { std: "/home/wuyf/doc_test/workspace/cargo-home/bin/rustup" "update" "stable", kill_on_drop: false }`
09:40:14 [INFO] [stderr] info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
09:40:15 [INFO] [stdout]
09:40:15 [INFO] [stdout]   stable-x86_64-unknown-linux-gnu unchanged - rustc 1.60.0 (7737e0b5c 2022-04-04)
09:40:15 [INFO] [stderr] info: checking for self-updates
09:40:15 [INFO] [stdout]
09:40:15 [INFO] tool git-credential-null is installed, trying to update it
09:40:15 [INFO] running `Command { std: "/home/wuyf/doc_test/workspace/cargo-home/bin/cargo" "+stable" "install" "git-credential-null", kill_on_drop: false }`
09:40:15 [INFO] [stderr]     Updating `sjtu` index
09:42:04 [INFO] [stderr] warning: spurious network error (2 tries remaining): unexpected http status code: 504; class=Http (34)
09:42:09 [INFO] [stderr]      Ignored package `git-credential-null v1.0.1` is already installed, use --force to override
09:42:09 [INFO] installing toolchain nightly-2022-04-15
09:42:09 [INFO] running `Command { std: "/home/wuyf/doc_test/workspace/cargo-home/bin/rustup" "toolchain" "install" "nightly-2022-04-15" "--profile" "minimal", kill_on_drop: false }`
09:42:09 [INFO] [stderr] info: syncing channel updates for 'nightly-2022-04-15-x86_64-unknown-linux-gnu'
09:42:09 [INFO] [stdout]
09:42:09 [INFO] [stdout]   nightly-2022-04-15-x86_64-unknown-linux-gnu unchanged - rustc 1.62.0-nightly (e7575f967 2022-04-14)
09:42:09 [INFO] [stderr] info: checking for self-updates
09:42:09 [INFO] [stdout]
09:42:10 [INFO] adding component rustc-dev for toolchain nightly-2022-04-15
09:42:10 [INFO] running `Command { std: "/home/wuyf/doc_test/workspace/cargo-home/bin/rustup" "component" "add" "--toolchain" "nightly-2022-04-15" "rustc-dev", kill_on_drop: false }`
09:42:10 [INFO] [stderr] info: component 'rustc-dev' for target 'x86_64-unknown-linux-gnu' is up to date
09:42:10 [INFO] crate rand 0.7.3 is already in cache
09:42:10 [INFO] extracting crate rand 0.7.3 into /home/wuyf/doc_test/workspace/builds/corpus/source
09:42:10 [INFO] validating manifest of crates.io crate rand 0.7.3 on toolchain nightly-2022-04-15
09:42:10 [INFO] running `Command { std: "/home/wuyf/doc_test/workspace/cargo-home/bin/cargo" "+nightly-2022-04-15" "metadata" "--manifest-path" "Cargo.toml" "--no-deps", kill_on_drop: false }`
09:42:10 [INFO] started tweaking crates.io crate rand 0.7.3
09:42:10 [INFO] finished tweaking crates.io crate rand 0.7.3
09:42:10 [INFO] tweaked toml for crates.io crate rand 0.7.3 written to /home/wuyf/doc_test/workspace/builds/corpus/source/Cargo.toml
09:42:10 [INFO] crate crates.io crate rand 0.7.3 already has a lockfile, it will not be regenerated
09:42:10 [INFO] running `Command { std: "/home/wuyf/doc_test/workspace/cargo-home/bin/cargo" "+nightly-2022-04-15" "fetch" "--manifest-path" "Cargo.toml", kill_on_drop: false }`
09:42:10 [INFO] running `Command { std: "docker" "create" "-v" "/home/wuyf/doc_test/workspace/builds/corpus/target:/opt/rustwide/target:rw,Z" "-v" "/home/wuyf/doc_test/workspace/builds/corpus/source:/opt/rustwide/workdir:ro,Z" "-v" "/home/wuyf/doc_test/workspace/cargo-home:/opt/rustwide/cargo-home:ro,Z" "-v" "/home/wuyf/doc_test/workspace/rustup-home:/opt/rustwide/rustup-home:ro,Z" "-e" "SOURCE_DIR=/opt/rustwide/workdir" "-e" "CARGO_TARGET_DIR=/opt/rustwide/target" "-e" "RUST_BACKTRACE=1" "-e" "SYSROOT=/opt/rustwide/cargo-home/sysroot" "-e" "RUSTC=/opt/rustwide/cargo-home/rustc" "-e" "CARGO_HOME=/opt/rustwide/cargo-home" "-e" "RUSTUP_HOME=/opt/rustwide/rustup-home" "-w" "/opt/rustwide/workdir" "-m" "4000000000" "--user" "0:0" "--network" "none" "ghcr.io/rust-lang/crates-build-env/linux@sha256:b0c94ce3c1162fcb8e57cac5b65ec2f72eabb1eebea4fcc35e269e823f681646" "/opt/rustwide/cargo-home/bin/cargo" "+nightly-2022-04-15" "check" "--all" "--frozen", kill_on_drop: false }`
09:42:10 [INFO] [stdout] 72b81e615e97f8fe2c68dd0b4e8ce92b79e45d0f37b335331f06f481b0bc735c
09:42:10 [INFO] [stderr] WARNING: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.
09:42:10 [INFO] running `Command { std: "docker" "start" "-a" "72b81e615e97f8fe2c68dd0b4e8ce92b79e45d0f37b335331f06f481b0bc735c", kill_on_drop: false }`
09:42:10 [INFO] [stderr] error: failed to get `getrandom` as a dependency of package `rand v0.7.3 (/opt/rustwide/workdir)`
09:42:10 [INFO] [stderr]
09:42:10 [INFO] [stderr] Caused by:
09:42:10 [INFO] [stderr]   failed to create directory `/opt/rustwide/cargo-home/registry/index/github.com-1ecc6299db9ec823`
09:42:10 [INFO] [stderr]
09:42:10 [INFO] [stderr] Caused by:
09:42:10 [INFO] [stderr]   Read-only file system (os error 30)
09:42:10 [INFO] running `Command { std: "docker" "inspect" "72b81e615e97f8fe2c68dd0b4e8ce92b79e45d0f37b335331f06f481b0bc735c", kill_on_drop: false }`
09:42:10 [INFO] running `Command { std: "docker" "rm" "-f" "72b81e615e97f8fe2c68dd0b4e8ce92b79e45d0f37b335331f06f481b0bc735c", kill_on_drop: false }`
09:42:10 [INFO] [stdout] 72b81e615e97f8fe2c68dd0b4e8ce92b79e45d0f37b335331f06f481b0bc735c
09:42:10 [ERROR] The target directory does not exist: "/home/wuyf/doc_test/workspace/builds/corpus/target/rust-corpus"
09:42:10 [INFO] Compilation succeeded.
wyf18 commented 2 years ago

I think I figured it out, my directory /home/wuyf/doc_test/workspace/cargo-home, it has all of dependencies I need. If I use crate.io index, it'll have /home/wuyf/doc_test/workspace/cargo-home/registry/src/github.com-1ecc6299db9ec823/, /home/wuyf/doc_test/workspace/cargo-home/registry/index/github.com-1ecc6299db9ec823/, /home/wuyf/doc_test/workspace/cargo-home/registry/cache/github.com-1ecc6299db9ec823/. But because of some network reasons, I changed the crate index to a mirror, so the directory changed to mirrors.sjtug.sjtu.edu.cn-7a04d2510079875b, but the docker image run as the same way. That's why this error happens, just my guess. I'm trying to change the crate index to official, but it's too slow :( Anyway, thanks for quick reply!

vakaras commented 2 years ago

Yes, that sounds like a possible cause.