Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo fetches submodules of git dependencies each time you run cargo update #10278

Closed
jyn514 opened this issue Jan 10, 2022 · 1 comment
Closed
Labels
C-bug Category: bug

Comments

@jyn514
Copy link
Member

jyn514 commented Jan 10, 2022

Problem

Cargo updates submodules much more frequently than it needs to; I think it's cloning the submodule fresh, when it could just reuse the submodule from the last update.

Steps

  1. cargo new cargo-submodule-weirdness && cd cargo-submodule-weirdness
  2. Paste the following into Cargo.toml:
[dependencies]
boring = { git = "https://github.com/cloudflare/boring", branch = "master" }
boring-sys = { git = "https://github.com/cloudflare/boring", branch = "master" }
hyper-boring = { git = "https://github.com/cloudflare/boring", branch = "master" }
tokio-boring = { git = "https://github.com/cloudflare/boring", branch = "master" }
  1. cargo update -p boring --precise 44426292e061ec7030b4e049528c876bba26deba
  2. cargo update -p boring --precise c85bf0940e13e92e085816718c6ae97fda8ca1aa

Note that cargo clones https://github.com/google/boringssl.git anew each time, even though it doesn't need to.

Possible Solution(s)

Reuse the cloned submodule between commits.

Notes

Log output for a --precise hash that cargo hasn't seen before:

[2022-01-10T23:22:55Z DEBUG cargo::core::workspace] find_root - trying /home/jnelson/rust-community/Cargo.toml
[2022-01-10T23:22:55Z DEBUG cargo::core::workspace] find_root - trying /home/jnelson/Cargo.toml
[2022-01-10T23:22:55Z DEBUG cargo::core::workspace] find_root - trying /home/Cargo.toml
[2022-01-10T23:22:55Z DEBUG cargo::core::workspace] find_root - trying /Cargo.toml
[2022-01-10T23:22:55Z DEBUG cargo::core::workspace] find_members - only me as a member
[2022-01-10T23:22:55Z DEBUG cargo::core::registry] load/missing  https://github.com/cloudflare/boring?branch=master#c4e1f474
[2022-01-10T23:22:55Z DEBUG cargo::core::registry] loading source https://github.com/cloudflare/boring?branch=master#c4e1f474
[2022-01-10T23:22:55Z DEBUG cargo::sources::config] loading: https://github.com/cloudflare/boring?branch=master#c4e1f474
[2022-01-10T23:22:55Z INFO  cargo::sources::git::utils] update submodules for: "/home/jnelson/.local/lib/cargo/git/checkouts/boring-2cc70a61acb7a8a8/c4e1f47/"
    Updating git submodule `https://github.com/google/boringssl.git`
[2022-01-10T23:22:55Z DEBUG cargo::sources::git::utils] can't use github fast path with `rev = "067cfd92f4d7da0edfa073b096d090b98a83b860"`
[2022-01-10T23:22:55Z DEBUG cargo::sources::git::utils] skipping gc as there's only 0 pack files
[2022-01-10T23:22:55Z DEBUG cargo::sources::git::utils] doing a fetch for https://github.com/google/boringssl.git
[2022-01-10T23:22:55Z DEBUG cargo::sources::git::utils] initiating fetch of ["+refs/heads/*:refs/remotes/origin/*", "+HEAD:refs/remotes/origin/HEAD"] from https://github.com/google/boringssl.git

and for a cached hash:

[2022-01-10T23:23:50Z DEBUG cargo::core::workspace] find_root - trying /home/jnelson/rust-community/Cargo.toml
[2022-01-10T23:23:50Z DEBUG cargo::core::workspace] find_root - trying /home/jnelson/Cargo.toml
[2022-01-10T23:23:50Z DEBUG cargo::core::workspace] find_root - trying /home/Cargo.toml
[2022-01-10T23:23:50Z DEBUG cargo::core::workspace] find_root - trying /Cargo.toml
[2022-01-10T23:23:50Z DEBUG cargo::core::workspace] find_members - only me as a member
[2022-01-10T23:23:50Z DEBUG cargo::core::registry] load/missing  https://github.com/cloudflare/boring?branch=master#c85bf094
[2022-01-10T23:23:50Z DEBUG cargo::core::registry] loading source https://github.com/cloudflare/boring?branch=master#c85bf094
[2022-01-10T23:23:50Z DEBUG cargo::sources::config] loading: https://github.com/cloudflare/boring?branch=master#c85bf094
[2022-01-10T23:23:50Z INFO  cargo::sources::git::utils] update submodules for: "/home/jnelson/.local/lib/cargo/git/checkouts/boring-2cc70a61acb7a8a8/c85bf09/"
[2022-01-10T23:23:50Z INFO  cargo::sources::git::utils] update submodules for: "/home/jnelson/.local/lib/cargo/git/checkouts/boring-2cc70a61acb7a8a8/c85bf09/boring-sys/deps/boringssl/"
[2022-01-10T23:23:50Z DEBUG cargo::ops::resolve] avoid_patch_ids={}

Version

cargo 1.59.0-nightly (fcef61230 2021-12-17)
release: 1.59.0-nightly
commit-hash: fcef61230c3b6213b6b0d233a36ba4ebd1649ec3
commit-date: 2021-12-17
host: x86_64-unknown-linux-gnu
libgit2: 1.3.0 (sys:0.13.23 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1l)
os: Pop!_OS 20.04 (focal) [64-bit]
@jyn514 jyn514 added the C-bug Category: bug label Jan 10, 2022
@ehuss
Copy link
Contributor

ehuss commented Jan 10, 2022

Yea, unfortunately cargo currently doesn't handle submodules well. I'm going to close as a duplicate of #7987, which contains a little more background information.

@ehuss ehuss closed this as completed Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants