rust-lang / rust-lang/cargo

Git fetch fails via dumb-https protocol

Open
#8,918 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-git C-bug S-blocked-external
Dominant language
Rust
Stars
15.5k
Forks
3k
Avg merge
23h 30m
Merged PRs (30d)
51

Description

Problem

I am setting up a self-hosted git repository. git itself has no problem accessing it but using it as a cargo dependency fails due to the server not sending a Content-Type header:

e@msi:~/Workbench/rust/tylisp$ cargo build
    Updating git repository `https://2-71828.com/git/typenum-uuid`
warning: spurious network error (2 tries remaining): no content-type header in response; class=Http (34)
warning: spurious network error (1 tries remaining): no content-type header in response; class=Http (34)
error: failed to get `typenum-uuid` as a dependency of package `tylisp v0.1.0 (/home/e/Workbench/rust/tylisp)`

Caused by:
  failed to load source for dependency `typenum-uuid`

Caused by:
  Unable to update https://2-71828.com/git/typenum-uuid

Caused by:
  failed to clone into: /home/e/.cargo/git/db/typenum-uuid-2731038279e3575f

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:
  no content-type header in response; class=Http (34)

Steps

  1. In a temporary directory, observe that git clone https://2-71828.com/git/typenum-uuid executes successfully.
  2. Add the following dependencies to Cargo.toml in a test project:
[dependencies]
typenum = "1.12.0"
typenum-uuid = { git = "https://2-71828.com/git/typenum-uuid" }
  1. Attempt to build the project

Notes

  • Output of cargo version: cargo 1.47.0 (f3c7e066a 2020-08-28)

  • The suggested net.git-fetch-with-cli configuration option is a valid workaround, but is necessary for any project that wishes to use this crate.

  • The relevant specifications are the git protocol specification:

Clients MUST NOT attempt to validate the returned Content-Type.

and the HTTP 1.1 specification:

If a Content-Type header field is not present, the recipient MAY either assume a media type of application/octet-stream (RFC2046, Section 4.5.1) or examine the data to determine its type.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with git clone and cargo build using the dependency and server URL from the report. Read Cargo's git-fetch handling and compare its Content-Type behavior with the cited Git and HTTP specifications. Done means the dependency fetch succeeds without requiring net.git-fetch-with-cli when the server omits that header.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.