Skip to content

zig fetch -h should include examples #20096

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

Closed
hippietrail opened this issue May 28, 2024 · 5 comments
Closed

zig fetch -h should include examples #20096

hippietrail opened this issue May 28, 2024 · 5 comments

Comments

@hippietrail
Copy link

hippietrail commented May 28, 2024

zig fetch -h or zig fetch --help currently tells us:

% zig fetch -h    
Usage: zig fetch [options] <url>
Usage: zig fetch [options] <path>

    Copy a package into the global cache and print its hash.

Options:
  -h, --help                    Print this help and exit
  --global-cache-dir [path]     Override path to global Zig cache directory
  --debug-hash                  Print verbose hash information to stdout
  --save                        Add the fetched package to build.zig.zon
  --save=[name]                 Add the fetched package to build.zig.zon as name
  --save-exact                  Add the fetched package to build.zig.zon, storing the URL verbatim
  --save-exact=[name]           Add the fetched package to build.zig.zon as name, storing the URL verbatim

But should ideally provide examples:

Which formats are supported? Tar and more recently Zip (I believe gzipped Tar is also supported?)

But then there's git URLs, which I believe are supported. Maybe I'm the only one who doesn't know enough about Git but my naïve attempts are not working.

After trying a bunch of things I realized I made some dumb mistakes like doing git fetch instead of zig fetch sometimes or doing zig fetch with a plain https schema instead of a git+https schema. I've removed the specifics which are not really useful.

So I'm assuming an example will help others besides me. (And perhaps there are multiple kinds of Git URLs that work?)

@andrewrk andrewrk closed this as not planned Won't fix, can't repro, duplicate, stale Aug 14, 2024
@tisonkun
Copy link
Contributor

tisonkun commented Oct 5, 2024

Why was this issue closed as not planned? Is it tracked else where?

I hit a case that the zig package is a subpath of the repo/tarball (here). And the build depends on another subpath to build the C lib.

Some document on zig fetch and the format of build.zig.zon file would be helpful ..

This page seems helpful to specify an alternative path to resolve the root path. But nothing about how zig fetch can work. (What kind of URL it expects.)

@mtlynch
Copy link
Contributor

mtlynch commented Feb 10, 2025

Any chance of reconsidering this issue? I just hit the same thing, and I couldn't figure out from the help output what URL I'm supposed to pass to zig fetch. A github HTTP URL? The .git URL?

This also is one of the top results when I search zig fetch in Kagi, so if anyone comes across this, I think the answer is that Zig fetch wants the path to the source tarball:

zig fetch --save https://github.com/JacobCrabill/zigdown/archive/refs/heads/main.tar.gz

@andrewrk
Copy link
Member

No, zig will not endorse one version control system over another, nor one code hosting service over another, by including examples of them.

@mtlynch
Copy link
Contributor

mtlynch commented Feb 10, 2025

It doesn't even have to be a real vendor. This would be fine:

zig fetch --save https://example.com/andrewrk/fun-example-tool/archive/refs/heads/main.tar.gz

Possibly in addition, are you open to more specificity in the help output to let the user know that the URL is supposed to be to a source tarball? Because currently the help text just says "url" without specifying what kind of URL it should be.

@andrewrk
Copy link
Member

Sure, that sounds like a nice enhancement 👍

Feel free to submit a patch.

mtlynch added a commit to mtlynch/zig that referenced this issue Feb 11, 2025
The current zig fetch help docs tell the user to specify a package's URL, but it's unclear what the URL should be.

This change expands the help output to explain what URLs the zig fetch command can handle and provides examples of valid URLs.

Related: ziglang#20096
mtlynch added a commit to mtlynch/zig that referenced this issue Feb 11, 2025
The current zig fetch help docs tell the user to specify a package's URL, but it's unclear what the URL should be.

This change expands the help output to explain what URLs the zig fetch command can handle and provides examples of valid URLs.

Related: ziglang#20096
mtlynch added a commit to mtlynch/zig that referenced this issue Feb 11, 2025
The current zig fetch help docs tell the user to specify a package's URL, but it's unclear what the URL should be.

This change expands the help output to explain what URLs the zig fetch command can handle and provides examples of valid URLs.

Related: ziglang#20096
andrewrk pushed a commit that referenced this issue Feb 13, 2025
The current zig fetch help docs tell the user to specify a package's URL, but it's unclear what the URL should be.

This change expands the help output to explain what URLs the zig fetch command can handle and provides examples of valid URLs.

Related: #20096

A git bundle file seems to be the more accurate term, as it's what git uses in its documentation: https://git-scm.com/docs/git-bundle
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

4 participants