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

GITHUB_TOKEN required? #33

Closed
magnusviri opened this issue Mar 8, 2023 · 14 comments
Closed

GITHUB_TOKEN required? #33

magnusviri opened this issue Mar 8, 2023 · 14 comments

Comments

@magnusviri
Copy link
Contributor

If I try to pkg build without GITHUB_TOKEN set then I get this message:

tea: installed: ~/Tea/pantry.extra/tea.out/cli.github.com/v2.24.0
no oauth token

If I set the GITHUB_TOKEN I get this error:

{
  rsp: Response {
  body: ReadableStream { locked: true },
  bodyUsed: true,
  headers: Headers {
  "access-control-allow-origin": "*",
  "access-control-expose-headers": "ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLim...",
  "content-length": "83",
  "content-security-policy": "default-src 'none'",
  "content-type": "application/json; charset=utf-8",
  date: "Wed, 08 Mar 2023 18:52:38 GMT",
  "referrer-policy": "origin-when-cross-origin, strict-origin-when-cross-origin",
  server: "GitHub.com",
  "strict-transport-security": "max-age=31536000; includeSubdomains; preload",
  vary: "Accept-Encoding, Accept, X-Requested-With",
  "x-content-type-options": "nosniff",
  "x-frame-options": "deny",
  "x-github-media-type": "github.v4; format=json",
  "x-github-request-id": "CCDC:3C37:3C3AEE7:7B87119:6408D976",
  "x-ratelimit-limit": "0",
  "x-ratelimit-remaining": "0",
  "x-ratelimit-reset": "1678305158",
  "x-ratelimit-resource": "graphql",
  "x-ratelimit-used": "0",
  "x-xss-protection": "0"
},
  ok: false,
  redirected: false,
  status: 401,
  statusText: "Unauthorized",
  url: "https://api.github.com/graphql"
},
  json: {
    message: "Bad credentials",
    documentation_url: "https://docs.github.com/graphql"
  }
}
error: Uncaught (in promise) Error
        throw new Error()
              ^
    at Object.getVersions (https://raw.githubusercontent.com/teaxyz/cli/v0.24.7/src/hooks/useGitHubAPI.ts:78:15)
    at async handleComplexVersions (https://raw.githubusercontent.com/teaxyz/cli/v0.24.7/src/hooks/usePantry.ts:339:20)
    at async Object.resolve (https://raw.githubusercontent.com/teaxyz/cli/v0.24.7/src/hooks/usePantry.ts:42:20)
    at async file:///opt/tea/tea.xyz/brewkit/v0.6.0/libexec/resolve.ts:23:15

This is the package yml file I'm trying to build (I haven't gotten very far yet).

distributable:
  url: https://github.com/apple-oss-distributions/libtelnet/archive/refs/tags/libtelnet-{{ version }}.tar.gz
  strip-components: 1

versions:
  github: user/repo/tags
  strip: /^libtelnet-/

build:
  dependencies:
    tea.xyz/gx/cc: c99
    tea.xyz/gx/make: '*'
  script: |
    echo hi
@jhheider
Copy link
Contributor

jhheider commented Mar 8, 2023

I had to search around for this a bit. I knew we documented it, but it was in around the fourth place I looked, which isn't great.

https://github.com/teaxyz/pantry.zero/wiki#personal-access-token

@jhheider
Copy link
Contributor

jhheider commented Mar 8, 2023

It has to do with using the GraphQL endpoint for getting tags instead of the API (due to shortcomings of the API), and rate limits (60/min for the API, 0/min for GraphQL without a PAT).

@magnusviri
Copy link
Contributor Author

I set the token and got the 401 unauthorized error. I set the "repo" -> "public_repo" permission. Maybe that's not enough anymore?

@jhheider
Copy link
Contributor

jhheider commented Mar 8, 2023

It's probably because user/repo doesn't exist. Try updating that to apple-oss-distributions/libtelnet

@magnusviri
Copy link
Contributor Author

Ok, that was dumb of me. Unfortunately that didn't fix it. I got the same error.

I wondered if maybe my version of brewkit was old so I rm -rd it. I then ran pkg, it installed, but now I get no feedback.

> pkg build
> pkg build
> pkg build apple.com/libtelnet
> pkg build apple.com/libtelnet

@magnusviri
Copy link
Contributor Author

It would be great if pkg had a --help flag.

@magnusviri
Copy link
Contributor Author

Line 32 (PKGS="$(sort.ts $PKGS --delimiter ' ')") doesn't work right. PKGS before line 32 is "apple.com/libtelnet". After line 32 it's empty.

Just an aside, since "user/repo" is now a template value, I bet someone besides me makes the same mistake again. I checked, and it's 404. So maybe user/repo could print an error or something. IDK. I almost want to go register that name and make a repo named repo so that we can prank people or something.

@magnusviri
Copy link
Contributor Author

Oh, "https://github.com/user" is taken. Shucks.

@magnusviri
Copy link
Contributor Author

I changed ./tea.out/tea.xyz/brewkit/v0.6.0/bin/pkg-build from PKGS="$(sort.ts $PKGS --delimiter ' ')" to sort.ts $PKGS --delimiter ' and I get this output.

/Users/james/Tea/pantry.extra_mag/tea.out/tea.xyz/brewkit/v0.6.0/bin/pkg-build: line 32:  7704 Killed: 9               sort.ts $PKGS --delimiter ' '

So sort.ts is dying. If I run sort.ts manually it works.

./tea.out/tea.xyz/brewkit/v0.6.0/libexec/sort.ts apple.com/libtelnet --delimiter ' '
apple.com/libtelnet

@mxcl
Copy link
Member

mxcl commented Mar 8, 2023

do pkg status. I bet it would show you a 1000 pkgs or something.

do pkg build [name-of-package] instead.

It would be great if pkg had a --help flag.

I guess if I stopped sleeping I’d have time 😭

@mxcl
Copy link
Member

mxcl commented Mar 8, 2023

A token is required yes, this is documented on the pantries.

Easiest way is gh auth login or whatever it is.

The 401 genuinely suggests the token is invalid. GitHub only give 401 for that AFAIK

@magnusviri
Copy link
Contributor Author

do pkg status. I bet it would show you a 1000 pkgs or something.

I started a fresh pantry so there was only the one package I'm working on.

It would be great if pkg had a --help flag.

I guess if I stopped sleeping I’d have time 😭

Sleeping is good. I modified the top of bin/pkg and added this (if no arg is present, then print the help).

arg="$1"
if test -z "$arg"; then
  exec pkg-help "$@"
fi
shift

Then I created a new file named bin/pkg-help. But instead of actually writing a help document, I decided to test things.

#!/bin/sh

set -e

d="$(cd "$(dirname "$0")"/.. && pwd)"
PATH="$d/libexec:$PATH"

echo `which tea`

It printed /Users/james/Tea/pantry.extra_mag/tea.out/tea.xyz/v0.24.3/bin/tea.

So, I ran that manually.

> /Users/james/Tea/pantry.extra_mag/tea.out/tea.xyz/v0.24.3/bin/tea
zsh: killed
> which tea
/opt/tea/tea.xyz/v0.24.9/bin/tea
> tea --version
tea 0.24.9

So, somehow my pantry tea was a different version (0.24.3) than the version that I had installed globally (0.24.9) and I'm guessing the pantry tea was loading stuff from the global version and that's why it died.

I deleted /Users/james/Tea/pantry.extra_mag/tea.out/tea.xyz/v0.24.3 and ran pkg build again and now it at leasts prints the original error. So I'm back to square 1.

> pkg status
apple.com/libtelnet
> pkg build
...
  ok: false,
  redirected: false,
  status: 401,
  statusText: "Unauthorized",
  url: "https://api.github.com/graphql"
},
  json: {
    message: "Bad credentials",
    documentation_url: "https://docs.github.com/graphql"
  }
}
error: Uncaught (in promise) Error
        throw new Error()
              ^
    at Object.getVersions (https://raw.githubusercontent.com/teaxyz/cli/v0.24.7/src/hooks/useGitHubAPI.ts:78:15)
    at async handleComplexVersions (https://raw.githubusercontent.com/teaxyz/cli/v0.24.7/src/hooks/usePantry.ts:339:20)
    at async Object.resolve (https://raw.githubusercontent.com/teaxyz/cli/v0.24.7/src/hooks/usePantry.ts:42:20)
    at async file:///Users/james/Tea/pantry.extra_mag/tea.out/tea.xyz/brewkit/v0.6.0/libexec/resolve.ts:23:15

@magnusviri
Copy link
Contributor Author

UGH. I hope I didn't cause you guys to spend much time debugging this. My PAT was bad. I made a new one and it worked.

@mxcl
Copy link
Member

mxcl commented Mar 9, 2023

Weird that the 0.24.3 version was dying… but let's just hope it was a bug in that version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants