Prototool wraps protoc for much of it's
functionality, and manages the downloading and caching of protoc and the Well-Known
Types definitions.
Prototool will automatically download and cache protoc if it has not already been downloaded,
however the command prototool cache update can manually manage this process See faq.md
for more details.
protoc is downloaded to the following directories based on flags and environment variables:
- If
--cache-pathis set, then this directory will be used. The user is expected to manually manage this directory, andprototool cache deletewill have no effect on it. - Otherwise, if
$PROTOTOOL_CACHE_PATHis set, then this directory will be used. The user is expected to manually manage this directory, andprototool cache deletewill have no effect on it. - Otherwise, if
$XDG_CACHE_HOMEis set, then$XDG_CACHE_HOME/prototoolwill be used. - Otherwise, if on Linux,
$HOME/.cache/prototoolwill be used, or on Darwin,$HOME/Library/Caches/prototoolwill be used.
By default, protoc version 3.11.0 is downloaded, however this is configurable in your
prototool.yaml file.
protoc:
version: 3.11.0Downloads are safe to run concurrently across processes, for example if using from Bazel, as Prototool implements file locking to make sure there is no contention on writing to the cache.
If one prefers to download and manage protoc and the Well-Known Types outside of Prototool,
this can be done in one of three ways.
- By setting the
--protoc-urlflag to provide an alternate URL to download theprotocZIP file from instead of GitHub Releases. This can be prefixed withfile://,http://, orhttps://, so one can either download the relevantprotocZIP file from GitHub Releases and store it locally, or upload the relevantprotocZIP file to i.e. s3 and download from therel. - By setting the
--protoc-bin-pathand--protoc-wkt-pathflags at runtime for relevant commands. The Well-Known Type path should be the directory that includes thegoogle/protobufdirectory containing the Well-Known Types. - By setting the
PROTOTOOL_PROTOC_BIN_PATHandPROTOTOOL_PROTOC_WKT_PATHenvironment variables, as we do in the provided Docker image. These variables are analagous to the--protoc-bin-pathand--protoc-wkt-pathflags, however the flags take precedence.
If any of these options are set, the protoc.version option in the prototool.yaml file is
ignored.