Skip to main content
Version: Next

Dependencies Overview

Dependencies let you declare what your command needs before it runs. Invowk™ validates all dependencies upfront and provides clear error messages when something's missing.

Why Declare Dependencies?​

Without dependency checks:

$ invowk cmd build
./scripts/build.sh: line 5: go: command not found

With dependency checks:

$ invowk cmd build

✗ Dependencies not satisfied!

Cannot run command 'build' because some dependencies are missing.

Missing Tools:
• go - not found in PATH

Fix the missing dependencies and try again, or update your invowkfile to remove unnecessary ones.

Much better! You know exactly what's wrong before anything runs.

Dependency Types​

Invowk supports six types of dependencies:

TypeChecks For
toolsBinaries in PATH
filepathsFiles or directories
cmdsOther Invowk commands
capabilitiesSystem capabilities
env_varsEnvironment variables
custom_checksCustom validation scripts

Basic Syntax​

Dependencies are declared in the depends_on block:

{
name: "build"
depends_on: {
tools: [
{alternatives: ["go"]}
]
filepaths: [
{alternatives: ["go.mod"]}
]
}
implementations: [...]
}

The Alternatives Pattern​

Every dependency uses an alternatives list with OR semantics:

// ANY of these tools satisfies the dependency
tools: [
{alternatives: ["podman", "docker"]}
]

// ANY of these files satisfies the dependency
filepaths: [
{alternatives: ["config.yaml", "config.json", "config.toml"]}
]

If any alternative is found, the dependency is satisfied. Invowk uses early return - it stops checking as soon as one matches.

Validation Order​

Host dependencies from the root, command, and implementation scopes are merged and validated in this order:

  1. env_vars - Environment variables (checked first!)
  2. tools - Binaries in PATH
  3. filepaths - Files and directories
  4. capabilities - System capabilities
  5. custom_checks - Custom validation scripts
  6. cmds - Other Invowk commands

In this host phase, environment variables are checked against the user environment captured when execution starts, before Invowk applies command-level environment values.

If the selected runtime is a container and it declares depends_on, Invowk then runs a second phase inside the container in the same order: environment variables, tools, filepaths, capabilities, custom checks, and commands. The first failed check stops its phase.

Scope Levels​

Host dependencies can be declared at three levels. A fourth, separate scope is available on the container runtime and is described under Container Runtime Dependencies.

Root Level (Global)​

Applies to all commands in the invowkfile:

depends_on: {
tools: [{alternatives: ["git"]}] // Required by all commands
}

cmds: [...]

Command Level​

Applies to a specific command:

{
name: "build"
depends_on: {
tools: [{alternatives: ["go"]}] // Required by this command
}
implementations: [...]
}

Implementation Level​

Applies to a specific implementation:

{
name: "build"
implementations: [
{
script: {content: "echo checking container dependencies"}
runtimes: [{name: "container", image: "debian:stable-slim"}]
platforms: [{name: "linux"}]
depends_on: {
// Implementation-level dependencies are validated on the host
tools: [{alternatives: ["sh"]}]
}
}
]
}

Scope Inheritance​

Dependencies are combined across levels:

// Root level: requires git
depends_on: {
tools: [{alternatives: ["git"]}]
}

cmds: [
{
name: "build"
// Command level: also requires go
depends_on: {
tools: [{alternatives: ["go"]}]
}
implementations: [
{
script: {content: "go build ./..."}
runtimes: [{name: "native"}]
platforms: [{name: "linux"}, {name: "macos"}]
// Implementation level: also requires make
depends_on: {
tools: [{alternatives: ["make"]}]
}
}
]
}
]

// Effective dependencies for "build": git + go + make

Runtime-Aware Validation​

Dependencies declared at root, command, or implementation level are always validated against the host system, regardless of the selected runtime. This ensures host-side prerequisites (like a container engine) are checked before execution begins.

To validate dependencies inside the container environment, use depends_on inside a container runtime block:

{
name: "build"
implementations: [
{
script: {content: "test -f /workspace/invowkfile.cue && echo ready"}
runtimes: [{
name: "container"
image: "debian:stable-slim"
depends_on: {
// Checked INSIDE the container
tools: [{alternatives: ["sh"]}]
filepaths: [{alternatives: ["/workspace/invowkfile.cue"]}]
}
}]
platforms: [{name: "linux"}]
// Host-level: always checked on the host
depends_on: {
tools: [{alternatives: ["docker", "podman"]}]
}
}
]
}

Container Runtime Dependencies​

The depends_on block inside a container runtime config validates against the container's environment. This is only available for the container runtime — native, virtual-sh, and virtual-lua runtimes do not support runtime-level depends_on.

ScopeValidated Against
Root / Command / Implementation depends_onAlways the host system
Container runtime depends_onThe container's environment

This separation lets you express both host and container requirements:

{
name: "deploy"
implementations: [{
script: {content: "./scripts/deploy.sh"}
runtimes: [{
name: "container"
image: "debian:stable-slim"
depends_on: {
// These are validated inside the container
tools: [{alternatives: ["kubectl"]}]
env_vars: [{alternatives: [{name: "KUBECONFIG"}]}]
}
}]
platforms: [{name: "linux"}]
// These are validated on the host (regardless of runtime)
depends_on: {
tools: [{alternatives: ["docker", "podman"]}]
env_vars: [{alternatives: [{name: "DOCKER_HOST"}]}]
}
}]
}

Only the selected runtime's depends_on is validated. If a command has multiple runtimes listed, deps for unselected runtimes are skipped.

Error Messages​

When dependencies aren't satisfied, Invowk shows a helpful error:

✗ Dependencies not satisfied!

Cannot run command 'deploy' because some dependencies are missing.

Missing Tools:
• docker - not found in PATH
• kubectl - not found in PATH

Missing or Inaccessible Files:
• Dockerfile: path does not exist

Missing or Invalid Environment Variables:
• AWS_ACCESS_KEY_ID - not set in environment

Fix the missing dependencies and try again, or update your invowkfile to remove unnecessary ones.

Complete Example​

Here's a command with multiple dependency types:

{
name: "deploy"
description: "Deploy to production"
depends_on: {
// Check environment first
env_vars: [
{alternatives: [{name: "AWS_ACCESS_KEY_ID"}, {name: "AWS_PROFILE"}]}
]
// Check required tools
tools: [
{alternatives: ["docker", "podman"]},
{alternatives: ["kubectl"]}
]
// Check required files
filepaths: [
{alternatives: ["Dockerfile"]},
{alternatives: ["k8s/deployment.yaml"]}
]
// Check network connectivity
capabilities: [
{alternatives: ["internet"]}
]
// Run other commands first
cmds: [
{alternatives: ["build"]},
{alternatives: ["test"]}
]
}
implementations: [
{
script: {content: "./scripts/deploy.sh"}
runtimes: [{name: "native"}]
platforms: [{name: "linux"}, {name: "macos"}]
}
]
}

Next Steps​

Learn about each dependency type in detail: