tilt icon indicating copy to clipboard operation
tilt copied to clipboard

Docs: `Ensure a tool is installed locally` fails with `Error in format: format: nested replacement fields not supported`

Open mbana opened this issue 3 years ago • 0 comments

https://docs.tilt.dev/snippets.html#snip_require_local_tool:

Ensure a tool is installed locally

Check that a command exists in PATH or fail the Tiltfile load.

$ tilt version
v0.30.5, built 2022-07-14
$ cat Tiltfile
# block Tiltfile execution if missing required tool (e.g. Helm)
def require_tool(tool):
    tool = shlex.quote(tool)
    local(
        cmd='command -v {tool} >/dev/null 2>&1 || { echo >&2 "{tool} is required but was not found in PATH"; exit 1; }'.format(
            tool=tool
        ),
        # `cmd_bat`, when present, is used instead of `cmd` on Windows.
        cmd_bat=[
            "powershell.exe",
            "-Noninteractive",
            "-Command",
            '& {{if (!(Get-Command {tool} -ErrorAction SilentlyContinue)) {{ Write-Error "{tool} is required but was not found in PATH"; exit 1 }}}}'.format(
                tool=tool
            ),
        ],
    )


require_tool("helm")
$ tilt up --stream
Tilt started on http://localhost:10350/
v0.30.5, built 2022-07-14

Initial Build
Loading Tiltfile at: /media/home/work/kubeshop.io/kusk-gateway/Tiltfile
ERROR: Traceback (most recent call last):
  /media/home/work/kubeshop.io/kusk-gateway/Tiltfile:20:13: in <toplevel>
  /media/home/work/kubeshop.io/kusk-gateway/Tiltfile:5:127: in require_tool
Error in format: format: nested replacement fields not supported

mbana avatar Jul 24 '22 13:07 mbana