nabijaczleweli / cargo-update

A cargo subcommand for checking and applying updates to installed executables
MIT License
1.21k stars 41 forks source link

[Bug] Crashes if `cargo install-update --all --git` #276

Open zerodegress opened 6 days ago

zerodegress commented 6 days ago

When I simply run cargo install-update --all --git, it crashes at the only crate from git.

log:

    Polling registry 'https://index.crates.io/'........

Package           Installed  Latest                           Needs update
cargo-binstall    v1.10.5    v1.10.5                          No
cargo-update      v14.1.1    v14.1.1                          No
cargo-wgsl        v0.0.16    v0.0.16                          No
create-tauri-app  v4.3.1     v4.3.1                           No
sccache           v0.8.1     v0.8.1                           No
tauri-cli         v1.6.2     v1.6.2 (v2.0.0-rc.15 available)  No
wasm-bindgen-cli  v0.2.93    v0.2.93                          No
wasm-opt          v0.116.1   v0.116.1                         No

No packages need updating.
克隆到纯仓库 '/tmp/cargo-update/cross'...
remote: Enumerating objects: 11110, done.
remote: Counting objects: 100% (2086/2086), done.
remote: Compressing objects: 100% (642/642), done.
remote: Total 11110 (delta 1663), reused 1680 (delta 1435), pack-reused 9024 (from 1)
接收对象中: 100% (11110/11110), 3.27 MiB | 2.33 MiB/s, 完成.
处理 delta 中: 100% (7615/7615), 完成.
thread 'main' panicked at /home/runner/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-update-14.1.1/src/ops/mod.rs:534:149:
called `Result::unwrap()` on an `Err` value: Error { code: -1, klass: 2, message: "could not stat '/tmp/cargo-update/cross/info/grafts': " }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

By the way, who is the user runner?

NobodyXu commented 6 days ago
called `Result::unwrap()` on an `Err` value: Error { code: -1, klass: 2, message: "could not stat '/tmp/cargo-update/cross/info/grafts': " }

Seems that the repository might be broken?

NobodyXu commented 6 days ago

By the way, who is the user runner?

If you are running this on GHA, then I guess it might be the default user of GHA that is used to run commands?

nabijaczleweli commented 6 days ago

I'm gonna assume "runner" is... you? At any rate, no other users are ever used.

The error looks like it points to the last line on

    fn pull_version_impl(&mut self, temp_dir: &Path, git_db_dir: &Path, http_proxy: Option<&str>, fork_git: bool) {
        let clone_dir = find_git_db_repo(git_db_dir, &self.url).unwrap_or_else(|| {
            fs::create_dir_all(temp_dir).unwrap();
            temp_dir.join(&self.name)
        });

        let repo = self.pull_version_repo(&clone_dir, http_proxy, fork_git);

        self.newest_id = Some(repo.and_then(|r| r.head().and_then(|h| h.target().ok_or_else(|| GitError::from_str("HEAD not a direct reference")))).unwrap());
    }

which should not be controversial.

What's the URL for the package you're updating? (you will see this in ~/.crates.toml)

zerodegress commented 5 days ago

What's the URL for the package you're updating? (you will see this in ~/.crates.toml)

I have installed the crate by:

cargo install cross --git https://github.com/cross-rs/cross
nabijaczleweli commented 1 day ago

I can't repro this. I've configured enough so it clones to that directory (and I don't have that file) but it works:

$ CARGO_NET_GIT_FETCH_WITH_CLI=a=true cargo install-update -g cross
Package  Installed  Latest  Needs update

No packages need updating.
Cloning into bare repository '/tmp/cargo-update/cross'...
remote: Enumerating objects: 11110, done.
remote: Counting objects: 100% (2086/2086), done.
remote: Compressing objects: 100% (642/642), done.
remote: Total 11110 (delta 1663), reused 1680 (delta 1435), pack-reused 9024 (from 1)
Receiving objects: 100% (11110/11110), 3.27 MiB | 4.93 MiB/s, done.
Resolving deltas: 100% (7615/7615), done.
Package  Installed                                 Latest                                    Needs update
cross    d8631fe4f4e8bb4c4b24417a35544857fb42ee23  d8631fe4f4e8bb4c4b24417a35544857fb42ee22  Yes

Updating cross from https://github.com/cross-rs/cross
    Updating git repository `https://github.com/cross-rs/cross`
$ l /tmp/cargo-update/cross/info/grafts
ls: /tmp/cargo-update/cross/info/grafts: No such file or directory
$ l /tmp/cargo-update/cross/info/exclude
-rw-r--r-- 1 nabijaczleweli users 240 09-21 00:13 /tmp/cargo-update/cross/info/exclude

Can you try deleting /tmp/cargo-update maybe to confirm this is not some stray state?