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

package manager can't download from bitbucket - Content-Type application/x-tar-gz #21314

Closed
travisstaloch opened this issue Sep 5, 2024 · 3 comments · Fixed by #21318
Closed
Labels
bug Observed behavior contradicts documented or intended behavior zig build system std.Build, the build runner, `zig build` subcommand, package management
Milestone

Comments

@travisstaloch
Copy link
Contributor

Zig Version

0.14.0-dev.1398+c34cfe486

Steps to Reproduce and Observed Behavior

Given a bitbucket url such as the following (which was found here).

// build.zig.zon
.dependencies = .{
        .@"zig-btree" = .{
            .url = "https://bitbucket.org/archaistvolts2/zig-btree/get/66e663379847757077d2b38e622318a77e8aa44d.tar.gz",

This error is shown.

$ zig version
0.14.0-dev.1398+c34cfe486
$ zig build
.../Code/zig/btreemapbuild.zig.zon:8:20: error: unrecognized 'Content-Type' header: 'application/x-tar-gz; charset=utf-8'
            .url = "https://bitbucket.org/archaistvolts2/zig-btree/get/66e663379847757077d2b38e622318a77e8aa44d.tar.gz",
                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This is only an issue for the .tar.gz url and not for the .zip url.

This diagnostic message is also missing a final '/'. I have omitted the beginning of the path.

.../Code/zig/btreemapbuild.zig.zon:8:20:

But should be.

.../Code/zig/btreemap/build.zig.zon:8:20:

Expected Behavior

The package manager should be able to download the package. And the diagnostic path should include a final '/'.

@travisstaloch travisstaloch added the bug Observed behavior contradicts documented or intended behavior label Sep 5, 2024
@Vexu Vexu added the zig build system std.Build, the build runner, `zig build` subcommand, package management label Sep 5, 2024
@Vexu Vexu added this to the 0.15.0 milestone Sep 5, 2024
@truemedian
Copy link
Contributor

This nonstandard mimetype should be added to the list of .tar.gz mime types in https://github.com/ziglang/zig/blob/master/src/Package/Fetch.zig#L1068-L1070

@travisstaloch
Copy link
Contributor Author

Thanks! I'll PR a patch which adds that line.

travisstaloch added a commit to travisstaloch/zig that referenced this issue Sep 5, 2024
Closes ziglang#21314

This allows the package manger to download tar.gz bitbucket urls.
travisstaloch added a commit to travisstaloch/zig that referenced this issue Sep 5, 2024
Closes ziglang#21314

This allows the package manger to download tar.gz bitbucket urls.
@travisstaloch
Copy link
Contributor Author

I think this patch would solve the diagnostic missing trailing '/' issue. But I'm not sure if there should be a runtime check that f.parent_package_root doesn't end with std.fs.path.sep_str. Can anyone confirm this is correct?

diff --git a/src/Package/Fetch.zig b/src/Package/Fetch.zig
index 2540cf9922..4272a71733 100644
--- a/src/Package/Fetch.zig
+++ b/src/Package/Fetch.zig
@@ -770,7 +770,7 @@ fn srcLoc(
     const eb = &f.error_bundle;
     const token_starts = ast.tokens.items(.start);
     const start_loc = ast.tokenLocation(0, tok);
-    const src_path = try eb.printString("{}" ++ Manifest.basename, .{f.parent_package_root});
+    const src_path = try eb.printString("{}" ++ std.fs.path.sep_str ++ Manifest.basename, .{f.parent_package_root});
     const msg_off = 0;
     return eb.addSourceLocation(.{
         .src_path = src_path,

@andrewrk andrewrk modified the milestones: 0.15.0, 0.14.0 Sep 6, 2024
DivergentClouds pushed a commit to DivergentClouds/zig that referenced this issue Sep 24, 2024
Closes ziglang#21314

This allows the package manger to download tar.gz bitbucket urls.
richerfu pushed a commit to richerfu/zig that referenced this issue Oct 28, 2024
Closes ziglang#21314

This allows the package manger to download tar.gz bitbucket urls.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior zig build system std.Build, the build runner, `zig build` subcommand, package management
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants