baml_language/crates/tools_stow/README.md
<a href="https://crates.io/crates/cargo-stow"></a> <a href="https://crates.io/crates/cargo-stow"></a> <a href="LICENSE"></a>
</div>cargo install cargo-stow
cargo stow init # Generate config
cargo stow # Validate (default)
cargo stow --fix # Auto-fix sortable issues
cargo stow --graph deps.svg # Generate dependency graph
Rust workspaces are powerful, but as they grow, they need governance:
| Feature | cargo-stow | cargo-deny | cargo-machete |
|---|---|---|---|
| Dependency sorting | ✅ | ❌ | ❌ |
| Workspace structure validation | ✅ | ❌ | ❌ |
| Crate naming conventions | ✅ | ❌ | ❌ |
| Dependency graph visualization | ✅ | ❌ | ❌ |
| Namespace/prefix enforcement | ✅ | ❌ | ❌ |
| License checking | ❌ | ✅ | ❌ |
| Unused dependency detection | ❌ | ❌ | ✅ |
cargo-stow fills the gap for workspace structure linting - use it alongside cargo-deny and cargo-machete for comprehensive workspace hygiene.
Run cargo stow init to generate a stow.toml configuration file:
# Define namespace(s) for your crates
[[namespaces]]
name = "myapp"
approved_prefixes = ["api", "cli"]
test_crate_exceptions = []
# Control which crates can depend on what
[[dependency_rules]]
pattern = "anyhow"
allowed_crates = ["*_cli"]
regular_deps_only = true
reason = "Use thiserror for library crates."
Alternatively, configure via [workspace.metadata.stow] in your Cargo.toml.
All crates must be directly under your crates directory - no nested crates.
The name field in Cargo.toml must match the folder name.
Crate names must follow: <namespace>_<word> or <namespace>_<prefix>_<word>
myapp_core - simple crate namemyapp_api_client - prefixed name (requires "api" in approved_prefixes)myapp_core_types - auto-allowed _types suffixmyapp_core_tests - auto-allowed _tests suffixCrates ending in _test or _tests must have a corresponding base crate.
All dependencies must use { workspace = true } format.
Configure rules to restrict which crates can use specific dependencies.
Dependencies are sorted: internal deps first (alphabetically), then external deps (alphabetically).
Running cargo stow --fix:
{ workspace = true } formatAdd to your GitHub Actions workflow:
- name: Install cargo-stow
run: cargo install cargo-stow
- name: Validate workspace structure
run: cargo stow
0 - All validations passed1 - Validation errors foundMIT