cargo-bins / cargo-binstall

Binary installation for rust projects
GNU General Public License v3.0
1.62k stars 60 forks source link

Install Info 401 Unauthorized #1962

Closed lvyuemeng closed 1 week ago

lvyuemeng commented 2 weeks ago

OS: windows11 Use binstall to install anything(for example: binstall itself) will output:

INFO resolve: Resolving package: 'cargo-binstall' INFO get_repo_info{self=Data { name: "cargo-binstall", version: "1.10.11", repo: Some("https://github.com/cargo-bins/cargo-binstall"), repo_info: OnceCell { value: None } }}:get_repo_info{repo=GhRepo { owner: "cargo-bins", repo: "cargo-binstall" }}:do_send_request{request=Request { method: POST, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("api.github.com")), port: None, path: "/graphql", query: None, fragment: None }, headers: {"accept": "application/vnd.github+json", "authorization": Sensitive} } url=https://api.github.com/graphql}: Received status code 401 Unauthorized, will wait for 120s and retry

NobodyXu commented 2 weeks ago

I think you might have provided an invalid github token.

cargo-binstall would only use GitHub GraphQL API jf a github token is provided, and since the API endpoint returns unauthorised, I think the github token you passed in might be invalid.

lvyuemeng commented 2 weeks ago

I think you might have provided an invalid github token.

cargo-binstall would only use GitHub GraphQL API jf a github token is provided, and since the API endpoint returns unauthorised, I think the github token you passed in might be invalid.

I didn't intentionally provide github token.(sorry if I omit something). What might cause this?

NobodyXu commented 2 weeks ago

cargo-binstall tries to find github token in

lvyuemeng commented 2 weeks ago

cargo-binstall tries to find github token in

  • env GITHUB_TOKEN
  • env GH_TOKEN
  • from gh auth token
  • from .git config

I don't have env GITHUB_TOKEN or GH_TOKEN, and gh auth token is fine, it prints the token. I'm still confused.

NobodyXu commented 2 weeks ago

gh auth token is fine, it prints the token. I'm still confused.

Is the token from gh auth token actually valid?

For example this graphql query copied from official doc:

gh api graphql -F owner='{owner}' -F name='{repo}' -f query='
  query($name: String!, $owner: String!) {
    repository(owner: $owner, name: $name) {
      releases(last: 3) {
        nodes { tagName }
      }
    }
  }
'
lvyuemeng commented 2 weeks ago

here the gh auth status

github.com ✓ Logged in to github.com account lvyuemeng (keyring)

  • Active account: true
  • Git operations protocol: https
  • Token: gho_****
  • Token scopes: 'gist', 'read:org', 'repo', 'workflow'
lvyuemeng commented 2 weeks ago

I try to use cargo binstall now, it works, but the problem becomes:

INFO Installing binaries... WARN Attempting at atomic rename failed: Access Denied。 (os error 5), fallback to other methods.

FIne... It seems occur only on the self update of cargo-binstall. I install trunk again, it works. : )

NobodyXu commented 2 weeks ago

FIne... It seems occur only on the self update of cargo-binstall. I install trunk again, it works. : )

We try to use atomic move to install binary, which might fail on Windows if it is currently running.

https://docs.rs/atomic-file-install/1.0.5/src/atomic_file_install/lib.rs.html#79-112

NobodyXu commented 2 weeks ago

I try to use cargo binstall now, it works, but the problem becomes:

Strange, could be hitting primary or secondary rate limit

lvyuemeng commented 2 weeks ago

I try to use cargo binstall now, it works, but the problem becomes:

Strange, could be hitting primary or secondary rate limit

I'm not expert for this, any underneath logic?

NobodyXu commented 2 weeks ago

The rate limit for restful/graphql API is applied by github:

https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api#:~:text=Primary%20rate%20limit%20for%20authenticated%20users&text=All%20of%20these%20requests%20count,of%2015%2C000%20requests%20per%20hour.

lvyuemeng commented 2 weeks ago

The rate limit for restful/graphql API is applied by github:

https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api#:~:text=Primary%20rate%20limit%20for%20authenticated%20users&text=All%20of%20these%20requests%20count,of%2015%2C000%20requests%20per%20hour.

Thanks for your patience!