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

fix(): error context for git_fetch refspec not found #14806

Merged
merged 3 commits into from
Nov 17, 2024

Conversation

dacianpascu06
Copy link
Contributor

@dacianpascu06 dacianpascu06 commented Nov 10, 2024

What does this PR try to resolve?

Fixes Issue : #14621

Adds more error context for fetching a commit that doesn't exists.

How should we test and review this PR?

I've created two tests, one for fast_path and one for libgit2.

r? @weihanglo

@rustbot
Copy link
Collaborator

rustbot commented Nov 10, 2024

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added A-git Area: anything dealing with git S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 10, 2024
@rustbot rustbot assigned weihanglo and unassigned epage Nov 10, 2024
tests/testsuite/git.rs Outdated Show resolved Hide resolved
src/cargo/sources/git/utils.rs Outdated Show resolved Hide resolved
tests/testsuite/git.rs Show resolved Hide resolved
@dacianpascu06 dacianpascu06 marked this pull request as ready for review November 17, 2024 15:02
src/cargo/sources/git/utils.rs Outdated Show resolved Hide resolved
tests/testsuite/git.rs Outdated Show resolved Hide resolved
src/cargo/sources/git/utils.rs Outdated Show resolved Hide resolved
src/cargo/sources/git/utils.rs Outdated Show resolved Hide resolved
src/cargo/sources/git/utils.rs Outdated Show resolved Hide resolved
src/cargo/sources/git/utils.rs Outdated Show resolved Hide resolved
src/cargo/sources/git/utils.rs Outdated Show resolved Hide resolved
src/cargo/sources/git/utils.rs Outdated Show resolved Hide resolved
@weihanglo weihanglo added the A-diagnostics Area: Error and warning messages generated by Cargo itself. label Nov 17, 2024
@dacianpascu06 dacianpascu06 force-pushed the git-fetch-error branch 2 times, most recently from e04acef to 6838bee Compare November 17, 2024 18:14
Comment on lines 4119 to 4143
[UPDATING] git repository `https://github.com/rust-lang/bitflags.git`
[WARNING] spurious network error (3 tries remaining): could not read from remote repository; class=Net (12); code=Eof (-20)
[WARNING] spurious network error (2 tries remaining): could not read from remote repository; class=Net (12); code=Eof (-20)
[WARNING] spurious network error (1 tries remaining): could not read from remote repository; class=Net (12); code=Eof (-20)
[ERROR] failed to get `bitflags` as a dependency of package `foo v0.1.0 ([ROOT]/foo)`

Caused by:
failed to load source for dependency `bitflags`

Caused by:
Unable to update https://github.com/rust-lang/bitflags.git?rev=11111b376b93484341c68fbca3ca110ae5cd2790

Caused by:
failed to clone into: [ROOT]/home/.cargo/git/db/bitflags-[HASH]

Caused by:
revision 11111b376b93484341c68fbca3ca110ae5cd2790 not found

Caused by:
network failure seems to have happened
if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli

Caused by:
could not read from remote repository; class=Net (12); code=Eof (-20)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is interesting that the error message doesn't seem to be emitted on GitHub Actions machine, but only on my local machine.

If it still happens, instead of asserting the entire message, try omitting some parts we're not interested in with ... (For the syntax, see https://doc.rust-lang.org/nightly/nightly-rustc/cargo_test_support/compare/index.html).

Suggested change
[UPDATING] git repository `https://github.com/rust-lang/bitflags.git`
[WARNING] spurious network error (3 tries remaining): could not read from remote repository; class=Net (12); code=Eof (-20)
[WARNING] spurious network error (2 tries remaining): could not read from remote repository; class=Net (12); code=Eof (-20)
[WARNING] spurious network error (1 tries remaining): could not read from remote repository; class=Net (12); code=Eof (-20)
[ERROR] failed to get `bitflags` as a dependency of package `foo v0.1.0 ([ROOT]/foo)`
Caused by:
failed to load source for dependency `bitflags`
Caused by:
Unable to update https://github.com/rust-lang/bitflags.git?rev=11111b376b93484341c68fbca3ca110ae5cd2790
Caused by:
failed to clone into: [ROOT]/home/.cargo/git/db/bitflags-[HASH]
Caused by:
revision 11111b376b93484341c68fbca3ca110ae5cd2790 not found
Caused by:
network failure seems to have happened
if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
Caused by:
could not read from remote repository; class=Net (12); code=Eof (-20)
[UPDATING] git repository `https://github.com/rust-lang/bitflags.git`
...
[ERROR] failed to get `bitflags` as a dependency of package `foo v0.1.0 ([ROOT]/foo)`
Caused by:
failed to load source for dependency `bitflags`
Caused by:
Unable to update https://github.com/rust-lang/bitflags.git?rev=11111b376b93484341c68fbca3ca110ae5cd2790
Caused by:
failed to clone into: [ROOT]/home/.cargo/git/db/bitflags-[HASH]
Caused by:
revision 11111b376b93484341c68fbca3ca110ae5cd2790 not found
...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the context:

---- git::git_fetch_libgit2_error_message stdout ----
running `/Users/runner/work/cargo/cargo/target/debug/cargo fetch`
thread 'git::git_fetch_libgit2_error_message' panicked at tests/testsuite/git.rs:4163:10:

---- expected: tests/testsuite/git.rs:4135:27
++++ actual:   stderr
   1    1 | [UPDATING] git repository `[https://github.com/rust-lang/bitflags.git`](https://github.com/rust-lang/bitflags.git%60)
   2      - [WARNING] spurious network error (3 tries remaining): could not read from remote repository; class=Net (12); code=Eof (-20)
   3      - [WARNING] spurious network error (2 tries remaining): could not read from remote repository; class=Net (12); code=Eof (-20)
   4      - [WARNING] spurious network error (1 tries remaining): could not read from remote repository; class=Net (12); code=Eof (-20)
   5    2 | [ERROR] failed to get `bitflags` as a dependency of package `foo v0.1.0 ([ROOT]/foo)`
   6    3 | 
   7    4 | Caused by:
   8    5 |   failed to load source for dependency `bitflags`
   9    6 | 
          ⋮
  15   12 | 
  16   13 | Caused by:
  17   14 |   revision 11111b376b93484341c68fbca3ca110ae5cd2790 not found
  18   15 | 
  19   16 | Caused by:
  20      -   network failure seems to have happened
  21      -   if a proxy or similar is necessary `net.git-fetch-with-cli` may help here
  22      -   https://doc.rust-lang.org/cargo/reference/config.html#netgit-fetch-with-cli
       17 +   Could not decode server reply
  23   18 | 
  24   19 | Caused by:
  25      -   could not read from remote repository; class=Net (12); code=Eof (-20)
       20 +   Unknown or unsupported header: "ERR upload-pack: not our ref 11111b376b93484341c68fbca3ca110ae5cd2790"
       ```

Copy link
Member

@weihanglo weihanglo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@weihanglo weihanglo added this pull request to the merge queue Nov 17, 2024
Merged via the queue into rust-lang:master with commit 010f171 Nov 17, 2024
20 checks passed
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 20, 2024
Update cargo

5 commits in 69e595908e2c420e7f0d1be34e6c5b984c8cfb84..66221abdeca2002d318fde6efff516aab091df0e
2024-11-16 01:26:11 +0000 to 2024-11-19 21:30:02 +0000
- Docs for optional registry JSON fields (rust-lang/cargo#14839)
- Allow registries to omit empty/default fields in JSON (rust-lang/cargo#14838)
- docs(unstable): Link to -Zwarnings issue, tracking issue (rust-lang/cargo#14836)
- fix(): error context for git_fetch refspec not found (rust-lang/cargo#14806)
- you we distinction (rust-lang/cargo#14829)
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 20, 2024
Update cargo

5 commits in 69e595908e2c420e7f0d1be34e6c5b984c8cfb84..66221abdeca2002d318fde6efff516aab091df0e
2024-11-16 01:26:11 +0000 to 2024-11-19 21:30:02 +0000
- Docs for optional registry JSON fields (rust-lang/cargo#14839)
- Allow registries to omit empty/default fields in JSON (rust-lang/cargo#14838)
- docs(unstable): Link to -Zwarnings issue, tracking issue (rust-lang/cargo#14836)
- fix(): error context for git_fetch refspec not found (rust-lang/cargo#14806)
- you we distinction (rust-lang/cargo#14829)
RalfJung pushed a commit to RalfJung/miri that referenced this pull request Nov 21, 2024
Update cargo

5 commits in 69e595908e2c420e7f0d1be34e6c5b984c8cfb84..66221abdeca2002d318fde6efff516aab091df0e
2024-11-16 01:26:11 +0000 to 2024-11-19 21:30:02 +0000
- Docs for optional registry JSON fields (rust-lang/cargo#14839)
- Allow registries to omit empty/default fields in JSON (rust-lang/cargo#14838)
- docs(unstable): Link to -Zwarnings issue, tracking issue (rust-lang/cargo#14836)
- fix(): error context for git_fetch refspec not found (rust-lang/cargo#14806)
- you we distinction (rust-lang/cargo#14829)
@weihanglo weihanglo added this to the 1.84.0 milestone Nov 28, 2024
lnicola pushed a commit to lnicola/rust-analyzer that referenced this pull request Nov 28, 2024
Update cargo

5 commits in 69e595908e2c420e7f0d1be34e6c5b984c8cfb84..66221abdeca2002d318fde6efff516aab091df0e
2024-11-16 01:26:11 +0000 to 2024-11-19 21:30:02 +0000
- Docs for optional registry JSON fields (rust-lang/cargo#14839)
- Allow registries to omit empty/default fields in JSON (rust-lang/cargo#14838)
- docs(unstable): Link to -Zwarnings issue, tracking issue (rust-lang/cargo#14836)
- fix(): error context for git_fetch refspec not found (rust-lang/cargo#14806)
- you we distinction (rust-lang/cargo#14829)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Error and warning messages generated by Cargo itself. A-git Area: anything dealing with git S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error message regression in Cargo 1.80 when fetching particular git revision
5 participants