Skip to content

crates_io (the library) not working for me. #9040

@jakobneufeld

Description

@jakobneufeld

Problem

When I use the search function on Registry with the host "https://crates.io"
Steps

  1. A new rust project
  2. Create a registry with Registry::new()
  3. Use the search function

Possible Solution(s)

Notes
This is what my code is
use crates_io::*; fn main() { let mut crates = Registry::new(String::from("https://crates.io"), None); let mut query = crates.search("clap",10).unwrap(); }
Also, this is the panic message:
thread 'main' panicked at 'called Result::unwrap() on an Err value: failed to get a 200 OK response, got 403
headers:
HTTP/2 403

    content-length: 667

    server: nginx

    date: Sun, 03 Jan 2021 15:32:18 GMT

    strict-transport-security: max-age=31536000

    via: 1.1 vegur, 1.1 9349ae4f82564896b96f5303b030d189.cloudfront.net (CloudFront)

    x-cache: Error from cloudfront

    x-amz-cf-pop: ZRH50-C1

    x-amz-cf-id: Y5DRl7OZ_nNIvAFIOkpmCig2tYjyWmfNPCX6MmAvnIVwrA0Q5aWJrA==

body:
We require that all requests include a User-Agent header. To allow us to determine the impact your bot has on our service, we ask that your user agent actually identify your bot, and not just report the HTTP client library you're using. Including contact information will also reduce the chance that we will need to take action against your bot.

Bad:
User-Agent: reqwest/0.9.1

Better:
User-Agent: my_crawler

Best:
User-Agent: my_crawler (my_crawler.com/info)
User-Agent: my_crawler (help@my_crawler.com)

If you believe you've received this message in error, please email help@crates.io and include the request id b8cb398a-10fb-4152-99f4-5e1a74571b02.

Output of cargo version:

cargo 1.47.0 (f3c7e06 2020-08-28)
macos big sur
x64

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-cargo-apiArea: cargo-the-library API and internal code issuesC-bugCategory: bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions