cli: Not working for org repos: "Could not resolve to a Repository"

Describe the bug

gh commands work for my personal repos but not for my company/organization repos. On the git cli page i could not find any setup documentation that tells me what to do to achieve that to work.

Steps to reproduce the behavior

gh version 0.5.4 (2020-02-13)
https://github.com/cli/cli/releases/tag/v0.5.4
  1. Type this: gh issue list (in fact any command that interacts with the repo)
  2. Error: ‘graphql error: ‘Could not resolve to a Repository with the name ‘[repo name]’.’’

Alternative trying with -R flag to include organization specifically

  1. Type this: gh issue list -R [organization]/[repo name]
  2. Error: ‘graphql error: ‘Could not resolve to a Repository with the name ‘[repo name]’.’’

Expected vs actual behavior

I expected the commands to work like they do for personal repos:

dotfiles on master [!] 
[I] ➜ gh issue list                 

Issues for florian-niefind/dotfiles

There are no open issues

Logs

Paste the activity from your command line: Already done above. Feel free to ask for any additional inputs you need.

Saw it is similar to this, but I did not see the same error messages there: https://github.com/cli/cli/issues/353

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 7
  • Comments: 19 (6 by maintainers)

Most upvoted comments

I started off getting this error which led me here.

❯ gh pr create                                                                                                
Warning: 1 uncommitted change                                                                                 
error checking for existing pull request: GraphQL error: Could not resolve to a Repository with the name '/'. 

❯ gh pr list

There are no open pull requests in org/repo-name (private repo)

Then tried:

If you keep getting the “Could not resolve to a Repository” error, please upgrade to an official release and re-authenticate by doing rm ~/.config/gh/config.yml and running a gh command again.

The config removal didn’t work, so I ran gh help and found gh auth (again, it’s been a while).

❯ gh auth login
? What account do you want to log into? GitHub.com
- Logging into github.com
read-only token in GITHUB_TOKEN cannot be modified

Then realized I did have a GITHUB_TOKEN environment variable so I unset/erased (fish) that and tried gh auth login again and it worked!!

Yes, brew install github/gh/gh is recommended for now.

We didn’t think that gh would be accepted to homebrew-core so soon since it’s beta software. In fact, it’s now deleted from homebrew-core because it was connected to the dev OAuth app instead of the main one, causing issues with org repos as described in this thread.

The OAuth app issue is now solved in master, but please for the time being use the official releases.

If you keep getting the “Could not resolve to a Repository” error, please upgrade to an official release and re-authenticate by doing rm ~/.config/gh/hosts.yml and running a gh command again.

I’m sorry for the trouble and thanks everyone for chiming in.

First of all, to clarify something: SSH vs. HTTPS in your repository’s git remote URLs should not matter at all for GitHub CLI. Feel free to use either. The linked issue mentioning SSH is not about gh not supporting SSH URLs, but about its authentication not working when gh is executed within the context of an ssh session, which is entirely different.

The most important differentiator for the issues described in this thread is how have you installed gh in the first place, i.e. whether you’ve downloaded a precompiled binary, compiled from source, or used community-maintained packages such as those for Arch Linux?

If you compiled from source or used a community-maintained package, can you visit https://github.com/settings/connections/applications/4d747ba5675d5d66553f and see if granting this OAuth app access to your organization helps? (You might need approval from your organization’s admin.) Otherwise, you can try downloading an official build from the releases page, which is the preferred solution in general.

I realize that this is supremely confusing. We will work on improving error messaging around these issues and, of course, try to make it so you don’t hit this in the first place. Thanks for all your help and patience!

I saw this once today. Second try worked though.

@bees you may be on to something - all of my organization’s repos are private, but I can access them. One of the main differences between your setup and mine - I am using a PAT for access instead of SSH keys. Looking at #286, ssh based access may not be supported yet.

Can you check with your coworkers to see how they are authenticating and how their remotes are set?

@v-y-a-s Please subscribe to https://github.com/cli/cli/issues/826 for updates on the topic 🙇

For the record I installed gh using Brew on macos

Reading #400, I think it’s the difference between installing gh from homebrew-core (brew install gh) versus from GitHub’s formula (brew install github/gh/gh). The latter is what’s being recommended at the moment.

@AjkayAlan it looks like they’re using PAT + HTTPS. I’ll change my setup, thanks for linking that issue!