Skip to content

Download GitHub database: fix gh invocation #10923

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

Merged
merged 1 commit into from
Jul 10, 2025
Merged

Conversation

dscho
Copy link
Contributor

@dscho dscho commented Oct 21, 2022

At least as of GitHub CLI v2.13.0, the leading slash in gh api /repos/... leads to a 404. In all GitHub CLI versions, the trailing slash of gh api .../databases/ seems to not be acceptable, either.

@dscho
Copy link
Contributor Author

dscho commented Sep 5, 2023

I should clarify that this happens on Windows, in Git Bash.

smowton
smowton previously approved these changes Sep 6, 2023
Copy link
Contributor

@smowton smowton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This appears to be accurate

@dscho
Copy link
Contributor Author

dscho commented Jul 7, 2025

@jketema so how is this PR supposed to proceed from here?

@jketema
Copy link
Contributor

jketema commented Jul 7, 2025

@dscho With gh version 2.74.2 it looks like that it works both with and without the / on both macOS and Ubuntu. Is this still broken with Git bash on Windows (this is not something I can easily check)?

When running `gh api /repos/...` in the Git Bash on Windows, it leads to
a 404. The reason is the automatic path conversion from "Unix-y" paths
on the command-line to proper Windows paths, as described in detail
https://www.msys2.org/docs/filesystem-paths/. Git Bash simply has no
chance to understnad that `/repos/...` is not referring to an absolute
path on the local filesystem.

Let's just skip the leading slash. This is as valid an invocation, and
sidesteps that path conversion on Windows.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho
Copy link
Contributor Author

dscho commented Jul 10, 2025

@jketema thank you for your response!

With gh version 2.74.2 it looks like that it works both with and without the / on both macOS and Ubuntu.

The crucial part is "on both macOS and Ubuntu", leaving out the still most prevalent platform: Windows.

Is this still broken with Git bash on Windows

Yes.

The reason is described in https://www.msys2.org/docs/filesystem-paths/: Git Bash needs to automatically convert paths on the command-line which look like Unix paths to look like Windows paths instead, when calling a Win32 program (which gh.exe is). And therefore it mistakes the /repos/... argument for a path in need of this conversion, leading to the 404.

I've updated the commit message to reflect this.

(this is not something I can easily check)?

I guess you could use the mxschmitt/action-tmate Action to check ;-)

@jketema
Copy link
Contributor

jketema commented Jul 10, 2025

@dscho thanks for your answer. Since either works on macOS and Ubuntu, I'm happy with this change.

@jketema jketema merged commit 18760b4 into github:main Jul 10, 2025
8 checks passed
@dscho dscho deleted the patch-1 branch July 10, 2025 09:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy