Skip to content

update

The update command generates and updates BUILD files by running Gazelle with all enabled language extensions.

Usage

Terminal window
bazelle update [flags] [path...]

Flags

FlagDescription
--checkCheck if BUILD files are up to date (exit 1 if changes needed)
--incrementalOnly update directories with changed source files
--forceForce full update, ignoring cached state
--languagesOnly run specific language extensions (comma-separated)
--verboseShow detailed output

Examples

Basic Update

Update all BUILD files in the current workspace:

Terminal window
bazelle update

Update a specific directory:

Terminal window
bazelle update ./src/mypackage

CI Integration

Check if BUILD files are up to date without modifying them:

Terminal window
bazelle update --check

Example CI output:

BUILD files need updating (3 file(s) would change)
Run 'bazelle update' to apply changes

Incremental Mode

For large codebases, incremental mode only updates directories with changed files:

Terminal window
bazelle update --incremental

How it works:

  1. On first run, Bazelle scans all source files and stores their hashes
  2. On subsequent runs, only directories with changed files are updated
  3. State is stored in .bazelle/ in your workspace root
Terminal window
# First run - full update, stores state
bazelle update --incremental
# Subsequent runs - only changed directories
bazelle update --incremental
# Force full update despite incremental flag
bazelle update --incremental --force

Language Filtering

Run only specific language extensions:

Terminal window
# Only Go and Kotlin
bazelle update --languages go,kotlin
# Only Python
bazelle update --languages python

Verbose Output

Show detailed information:

Terminal window
bazelle update --verbose

Example verbose output:

Languages: go, kotlin, python, cc
Processing 847 files in 123 packages...
Updated: src/auth/BUILD.bazel
Updated: src/api/BUILD.bazel
Unchanged: 121 packages
State saved (847 files tracked)

Passthrough Flags

Flags not recognized by Bazelle are passed to Gazelle:

Terminal window
# Set Go prefix (passed to gazelle)
bazelle update -go_prefix=github.com/org/repo
# Use bzlmod mode
bazelle update -bzlmod
# Specify build tags
bazelle update -build_tags=integration

Exit Codes

CodeModeMeaning
0NormalUpdate completed successfully
0--checkBUILD files are up to date
1--checkBUILD files need updating
1AnyError occurred

Comparison with fix

CommandChangesUse Case
updateAdditive onlyRegular development
fixMay delete/rename rulesMajor 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.