Skip to content

cargo install fails to build patch-hub #119

@ivinjabraham

Description

@ivinjabraham

Description:

While adding a section about using cargo install to install the binary on a system for README.md, I noticed that the build fails due to a surprising ureq trait bound not being satsified.


error[E0277]: the trait bound `std::option::Option<std::string::String>: Into<AutoHeaderValue>` is not satisfied
   --> src/lore/lore_api_client.rs:31:25
    |
31  |               .user_agent(Some(format!(
    |  ______________----------_^
    | |              |
    | |              required by a bound introduced by this call
32  | |                 "kworkflow/patch-hub/",
33  | |             )))
    | |______________^ the trait `AsRef<str>` is not implemented for `std::option::Option<std::string::String>`, which is required by `std::option::Option<std::string::String>: Into<AutoHeaderValue>`
    |
    = note: required for `AutoHeaderValue` to implement `From<std::option::Option<std::string::String>>`
    = note: required for `std::option::Option<std::string::String>` to implement `Into<AutoHeaderValue>`
note: required by a bound in `ConfigBuilder::<Scope>::user_agent`
   --> /home/ivin/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ureq-3.0.9/src/config.rs:528:41
    |
528 |     pub fn user_agent(mut self, v: impl Into<AutoHeaderValue>) -> Self {
    |                                         ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `ConfigBuilder::<Scope>::user_agent`

Despite the function signature being:

    /// Value to use for the `User-Agent` field.
    ///
    /// This can be overridden by setting a `user-agent` header on the request
    /// object. The one difference is that a connection to a HTTP proxy server
    /// will receive this value, not the request-level one.
    ///
    /// Defaults to `None`, which results in `ureq/<version>`
    pub fn user_agent(mut self, v: Option<String>) -> Self {
        self.config().user_agent = v;
        self
    }

How to reproduce:

  1. Run cargo install --path .
  2. Wait for it to download crates and compile patch-hub.

Expected behavior:

cargo install is able to successfully compile the project just like cargo build and cargo run.

Setup:

  • Project branch: master
  • Project commit hash: cf72c40

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working properlywaiting-stableWaiting merging into the master branch

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions