Tools
Tool definitions
Each tool definition shares a set of attributes:
Field | |
---|---|
| The name of the tool. Must be unique. |
| The default version to initialize the tool at (required). |
| A list of binaries exposed by the tool. Each of these will correspond to one identically named executable installed in |
| You can specify an environment for the tool. We provide the |
Note: If the tool has a
runtime
attribute, the runtime's environment is merged in to its environment (discussed in the examples below).
Broadly speaking, there are 3 kinds of tools - download, package, and runtime-based tools. We'll look at each one in turn:
Download-based tools
Download-based tools are straightforward: They reference a named download configuration in the global downloads
section. Here is an example:
Note that for the downloaded archive, the binary named gh
is inside the bin
directory, so we use the environment to point the $PATH
there.
Download fields
strip_components
: This number of leading directory components to remove from all files in an archive when extracting.
rename_single_file
: If an archive contains a single file, this will cause that file to be renamed to the name of the tool. This is most useful for downloads of gzip'd binaries with the platform name in the binary.
Package-based tools
Package-based tools depend on specified package
and runtime
attributes. Here is an example of configuring mypy
as a tool:
extra_packages
behaves equivalently to a package file like requirements.txt
for Python or package.json
for Node. They can be optionally pinned at versions.
The version of the primary package (in this case, mypy
) is specified in the tools.enabled
. So to enable the mypy
tool at 1.4.0
, list it as - mypy@1.4.0
.
If you don't want to include additional packages in the tool definition, you can instead make them explicit in the enabled section of your .trunk/trunk.yaml
as you would for linters, for example:
Runtime-based tools
Runtime-based tools are a special case that are not explicitly defined. Rather, each runtime object exposes a set of shims
(just like tool
definitions).
If the runtime is enabled and listed in tools.runtimes
, then shims exposed by that runtime are automatically installed in the .trunk/tools
directory alongside those of other tools (trunk tools enable <runtime_tool>
does that for you). Thus you can run python
, pip
, etc as trunk
-managed tools.
Example:
If this is disruptive to your workflow, simply remove the runtime's name (go, node, python,...)
from tools.runtimes
section or run trunk tools disable <runtime_name>
which will handle it for you. Runtimes cannot be enabled or versioned via the tools.enabled
section, however, and runtimes must be enabled in the runtimes
section to be available to have their shims installed.
Last updated