Buck: http_file()


This is liable to change in the future.

An http_file() rule is used to download files from the Internet to be used as dependencies for other rules. This rule only downloads single files, and can optionally make them executable (see executable) These rules are downloaded by running buck fetch, or can be downloaded as part of buck build by setting download.in_build


  • name (required) #

    The name of the rule. This is used in the filename on disk if  out  is not provided.

  • urls (required) #

    A list of urls to attempt to download from. They are tried in order, and subsequent ones are only tried if the download fails. If validation fails, a new URL is not used. Supported protocols are "http" and "https".

  • sha256 (required) #

    The SHA-256 hash of the downloaded artifact. Buck verifies this is correct and fails the fetch command if it doesn't match in order to guarantee repeatable builds.

  • out (defaults to None) #

    An optional name to call the downloaded artifact. Buck will generate a default name if one is not provided that uses the name of the rule.

  • executable (required) #

    Whether or not the file should be made executable after downloading. If true, this can also be used via buck run and the $(exe ) string parameter macros

  • visibility (defaults to []) #

    List of build target patterns that identify the build rules that can include this rule in its deps.

  • licenses (defaults to []) #

    Set of license files for this library. To get the list of license files for a given build rule and all of its dependencies, you can use buck query.

  • labels (defaults to []) #

    Set of arbitrary strings which allow you to annotate a build rule with tags that can be searched for over an entire dependency tree using buck query attrfilter.


Using http_file(), third party packages can be downloaded from an https URL and used in java libraries.

  name = 'guava-23-bin',
  urls = [
  sha256 = '7baa80df284117e5b945b19b98d367a85ea7b7801bd358ff657946c3bd1b6596',
  name = 'guava-23-sources',
  urls = [
  sha256 = '37fe8ba804fb3898c3c8f0cbac319cc9daa58400e5f0226a380ac94fb2c3ca14',

  name = 'guava-23',
  binary_jar = ':guava-23-bin',
  source_jar = ':guava-23-source',

Tooling can also be fetched with http_file() and used by a genrule.

  cmd="$(exe :thrift-compiler-bin) --gen cpp2 -o $OUT $(location //:thrift-file)",

  name = 'thrift-compiler-bin',
  url = 'https://internal-mirror.example.com/bin/thrift-compiler',
  sha256 = 'c24932ccabb66fffb2d7122298f7f1f91e0b1f14e05168e3036333f84bdf58dc',