Repository navigation
gh pr edit https://... --add-label ... does not deduce --repo from the URL automatically #11055
Description
Activity
Thanks for reporting this! 🙏 Checking the other issue you linked, I assume this is the command you're trying to run:
gh pr edit https://github.com/sagemath/sage/pull/40192 --add-label "s: needs review"If so, could you please run it with the
GH_DEBUG=apienv var and share the output with me? I mean:GH_DEBUG=api gh pr edit https://github.com/sagemath/sage/pull/40192 --add-label "s: needs review"Please don't forget to remove unnecessary/private details.
I wonder if this might have the same underlying reason as #10071 (comment)
Reacted by user202729I test on my fork
[b]$ gh pr edit https://github.com/user202729/sage/pull/1 --add-label "test label" failed to run git: fatal: not a git repository (or any parent up to mount point /) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). [b]$ GH_DEBUG=api gh pr edit https://github.com/user202729/sage/pull/1 --add-label "test label" [git remote -v] failed to run git: fatal: not a git repository (or any parent up to mount point /) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).Only difference is
[git remote -v].Reacted by Babak K. Shandiz@williammartin, Seems like we have a circular kind of dependency to
BaseRepo:Lines 207 to 222 in b4ab343
findOptions := shared.FindOptions{ Selector: opts.SelectorArg, Fields: []string{"id", "url", "title", "body", "baseRefName", "reviewRequests", "labels", "projectCards", "projectItems", "milestone"}, Detector: opts.Detector, } httpClient, err := opts.HttpClient() if err != nil { return err } if opts.Detector == nil { baseRepo, err := opts.BaseRepo() if err != nil { return err } Here, we need a
Detector(to make sure we're using the available API features), but to create that we need to know the host. Since, the current directory is not a git repo, call toBaseRepofails, and so we return with that error.As a quick solution, we can check if the
SelectorArgis a valid PR URL and grab the host name from that. However, I have to check and see in how many places we're doing this and would need to apply this fix.What do you think?
UPDATE: Basically, this means we have to export the Finder's
parseURLmethod and use it ineditRun:cli/pkg/cmd/pr/shared/finder.go
Line 305 in b4ab343
func (f *finder) parseURL(prURL string) (ghrepo.Interface, int, error) { Reacted by freganteJust released https://github.com/cli/cli/releases/tag/v2.74.1 which should resolve this. Unfortunately, it might take a little time to get into the runner images so in the meantime you might want to use the Installation Instructions to manually pull the release in (and I'd certainly appreciate if anyone did this to verify our fix as well).
Extremely sorry for the inconvenience 🙏
Reacted by fregante and Babak K. Shandiz- added a commit that references this issue
on Jun 13, 2025 so in the meantime you might want to use the Installation Instructions to manually pull the release in (and I'd certainly appreciate if anyone did this to verify our fix as well).
So we tried this by doing
apt-get update; apt-get install ghand the apt repo does not appear to have the fix either:gh is already the newest version (2.74.0)- added a commit that references this issue
on Jun 13, 2025 @danakj not sure about that, it is definitely in the repo.
curl https://cli.github.com/packages/dists/stable/main/binary-amd64/Packages.gz --output - | gunzip Package: gh Version: 2.74.1 Architecture: amd64 Maintainer: GitHub Installed-Size: 36977 Depends: git Homepage: https://github.com/cli/cli Priority: optional Section: Filename: pool/main/g/gh/gh_2.74.1_amd64.deb <--------- Size: 14194750 SHA256: c3d909c338589589b32ee2357a76cea3b2c7bdfe1754ab8a62316fa846692935 SHA1: 4dd7505ada041a5d2af49d5a9ac922e195c7ada1 MD5sum: 375068bfa991fcd39bae560961d2c3d9 Description: GitHub’s official command line tool.Interesting, dunno. We solved this another way by adding
--repoto the command line for now.
Describe the bug
As in the title.
Affected version
gh version 2.73.0 (2025-05-19)
This previously worked in gh version 2.72.0 (2025-04-30)
Steps to reproduce the behavior
As in the title.
This affects SageMath's action: sagemath/sage#40193