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-path
is set, then this directory will be used. The user is expected to manually manage this directory, andprototool cache delete
will have no effect on it. - Otherwise, if
$PROTOTOOL_CACHE_PATH
is set, then this directory will be used. The user is expected to manually manage this directory, andprototool cache delete
will have no effect on it. - Otherwise, if
$XDG_CACHE_HOME
is set, then$XDG_CACHE_HOME/prototool
will be used. - Otherwise, if on Linux,
$HOME/.cache/prototool
will be used, or on Darwin,$HOME/Library/Caches/prototool
will be used.
By default, protoc
version 3.8.0
is downloaded, however this is configurable in your
prototool.yaml
file.
protoc:
version: 3.8.0
Downloads 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-url
flag to provide an alternate URL to download theprotoc
ZIP file from instead of GitHub Releases. This can be prefixed withfile://
,http://
, orhttps://
, so one can either download the relevantprotoc
ZIP file from GitHub Releases and store it locally, or upload the relevantprotoc
ZIP file to i.e. s3 and download from therel. - By setting the
--protoc-bin-path
and--protoc-wkt-path
flags at runtime for relevant commands. The Well-Known Type path should be the directory that includes thegoogle/protobuf
directory containing the Well-Known Types. - By setting the
PROTOTOOL_PROTOC_BIN_PATH
andPROTOTOOL_PROTOC_WKT_PATH
environment variables, as we do in the provided Docker image. These variables are analagous to the--protoc-bin-path
and--protoc-wkt-path
flags, however the flags take precedence.
If any of these options are set, the protoc.version
option in the prototool.yaml
file is
ignored.