update
The update command generates and updates BUILD files by running Gazelle with all enabled language extensions.
Usage
bazelle update [flags] [path...]Flags
| Flag | Description |
|---|---|
--check | Check if BUILD files are up to date (exit 1 if changes needed) |
--incremental | Only update directories with changed source files |
--force | Force full update, ignoring cached state |
--languages | Only run specific language extensions (comma-separated) |
--verbose | Show detailed output |
Examples
Basic Update
Update all BUILD files in the current workspace:
bazelle updateUpdate a specific directory:
bazelle update ./src/mypackageCI Integration
Check if BUILD files are up to date without modifying them:
bazelle update --checkExample CI output:
BUILD files need updating (3 file(s) would change)Run 'bazelle update' to apply changesIncremental Mode
For large codebases, incremental mode only updates directories with changed files:
bazelle update --incrementalHow it works:
- On first run, Bazelle scans all source files and stores their hashes
- On subsequent runs, only directories with changed files are updated
- State is stored in
.bazelle/in your workspace root
# First run - full update, stores statebazelle update --incremental
# Subsequent runs - only changed directoriesbazelle update --incremental
# Force full update despite incremental flagbazelle update --incremental --forceLanguage Filtering
Run only specific language extensions:
# Only Go and Kotlinbazelle update --languages go,kotlin
# Only Pythonbazelle update --languages pythonVerbose Output
Show detailed information:
bazelle update --verboseExample verbose output:
Languages: go, kotlin, python, ccProcessing 847 files in 123 packages...Updated: src/auth/BUILD.bazelUpdated: src/api/BUILD.bazelUnchanged: 121 packagesState saved (847 files tracked)Passthrough Flags
Flags not recognized by Bazelle are passed to Gazelle:
# Set Go prefix (passed to gazelle)bazelle update -go_prefix=github.com/org/repo
# Use bzlmod modebazelle update -bzlmod
# Specify build tagsbazelle update -build_tags=integrationExit Codes
| Code | Mode | Meaning |
|---|---|---|
| 0 | Normal | Update completed successfully |
| 0 | --check | BUILD files are up to date |
| 1 | --check | BUILD files need updating |
| 1 | Any | Error occurred |
Comparison with fix
| Command | Changes | Use Case |
|---|---|---|
update | Additive only | Regular development |
fix | May delete/rename rules | Major refactoring |
Use update for day-to-day development. Use fix when you’ve renamed or deleted source files and need to clean up obsolete BUILD rules.