Skip to content

download_and_extract function in repository_ctx does not support .tbz file extension #17824

@benji-sb

Description

@benji-sb

Description of the bug:

The download_and_extract function from repository_ctx can handle .tar.bz2 archives just fine, but it does not recognize the .tbz file extension.

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Use a call to the http_archive function from @bazel_tools//tools/build_defs/repo:http.bzl that tries to download a .tbz file, eg:

http_archive(
        name = "opam_fmt",
        url = "https://erratique.ch/software/fmt/releases/fmt-0.9.0.tbz",
        strip_prefix = "fmt-0.9.0",
        build_file = "@//saq/common/build/ocaml:fmt.BUILD.bazel",
        type = "tar.bz2",
    )

It will raise an error like:

Error in download_and_extract: Expected a file with a .zip, .jar, .war, .aar, .tar, .tar.gz, .tgz, .tar.xz, .txz, .tar.zst, .tzst, .tar.bz2, .ar or .deb suffix (got /home/bsu/.cache/bazel/_bazel_bsu/6ee5cfe95d49437cbae81099cbfd479d/external/opam_fmt/temp479414337524270073/fmt-0.9.0.tbz)

Which operating system are you running Bazel on?

Debian testing

What is the output of bazel info release?

release 6.0.0-pre.20221012.2

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

[email protected]:benjamin-sb/bazel.git
952438d4c7c69beec3a1dc643d564c116e0e1542
2378e2d34f7a64007e6b2c96410261e416f737b2

Have you found anything relevant by searching the web?

No. Best we could come up with was using a wrapper that checks for the file extension and manually enforcing type=".tar.bz2" when necessary, but this is clearly a hacky workaround that we'd like to avoid.

Any other information, logs, or outputs that you want to share?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3We're not considering working on this, but happy to review a PR. (No assignee)team-ExternalDepsExternal dependency handling, remote repositiories, WORKSPACE file.type: feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions