Module Dependencies Overview
Module dependencies are still being refined. While we aim for backwards compatibility, breaking changes may occur before the 1.0 release. Lock files keep builds reproducible, but resolution behavior may evolve.
Module dependencies let a module pull in commands from other modules hosted in Git repositories. Dependencies are declared in invkmod.cue under requires and resolved into invkmod.lock.cue.
What are Module Dependencies?
Module dependencies are external modules that your module depends on. They are:
- Hosted in Git repositories (GitHub, GitLab, Bitbucket, etc.)
- Versioned with semantic versioning (tags like
v1.2.3or1.2.3) - Cached locally for offline use and performance
- Namespaced by module ID or alias to prevent collisions
Quick Start
1. (Optional) Resolve a Dependency
invowk module add resolves a dependency and prints the requires entry you can copy into invkmod.cue:
invowk module add https://github.com/example/common.invkmod.git ^1.0.0
2. Declare in invkmod.cue
module: "com.example.mytools"
version: "1.0"
description: "My tools"
requires: [
{
git_url: "https://github.com/example/common.invkmod.git"
version: "^1.0.0"
alias: "common"
},
]
3. Sync Dependencies
invowk module sync
4. Verify Resolved Dependencies
invowk module deps
Namespaces and Aliases
When a dependency module is installed in a discovery path, run its commands with the module ID (or alias if you set one):
# Default namespace includes the resolved version
invowk cmd com.example.common@1.2.3 build
# With alias
invowk cmd common build
How It Works
- Declaration: Dependencies are listed in
invkmod.cueunderrequires - Resolution:
invowk module syncresolves version constraints to concrete versions - Download: Modules are cloned from Git and cached locally
- Lock file: Resolved versions are written to
invkmod.lock.cue - Discovery: Commands are available via the module namespace when the dependency is installed
Commands in a module can only call commands from:
- The same module
- Globally installed modules (your discovery paths)
- Modules declared directly in that module's
requireslist
Transitive dependencies are resolved and cached, but their commands are not in scope unless they are also listed directly.
Module Cache
Module dependencies are cached in ~/.invowk/modules/ by default:
~/.invowk/modules/
├── sources/
│ └── github.com/
│ └── example/
│ └── common.invkmod/
└── github.com/
└── example/
└── common.invkmod/
└── 1.2.3/
├── invkmod.cue
└── invkfile.cue
Override the cache location:
export INVOWK_MODULES_PATH=/custom/cache/path
Next Steps
- Declaring Dependencies - Learn the
requiressyntax - CLI Commands - Module dependency management commands
- Lock File - Understanding the lock file format