Troubleshooting
This guide helps you diagnose and fix common issues with Bazelle.
Diagnostic Commands
Before troubleshooting, gather information:
# Check Bazelle versionbazelle version
# Run with verbose loggingbazelle -v 3 update
# Run with trace logging (very detailed)bazelle -v 4 update
# Check what would change without applyingbazelle fix --dry-runCommon Issues
”No languages detected” during init
Symptom: bazelle init reports no languages found.
Causes:
- No source files in recognized locations
- Files use unexpected extensions
Solution:
- Verify source files exist in your project
- Check file extensions match expected patterns:
- Go:
.go - Kotlin:
.kt,.kts - Python:
.py - C/C++:
.c,.cc,.cpp,.h,.hpp
- Go:
- Use
--languagesflag to specify manually:Terminal window bazelle init --languages go,kotlin
Language not generating rules
Symptom: Running bazelle update doesn’t generate rules for your language.
Causes:
- Language not enabled
- Files not in expected directory structure
- Directory is excluded
Solution:
# 1. Enable Kotlin in root BUILD.bazel# gazelle:kotlin_enabled trueKotlin requires Maven-style layout:
src/main/kotlin/ → kt_jvm_librarysrc/test/kotlin/ → kt_jvm_test# 1. Enable Python in root BUILD.bazel# gazelle:python_enabled truePython works with any .py files in the directory.
BUILD file conflicts
Symptom: Error about conflicting rules or duplicate targets.
Causes:
- Multiple extensions trying to generate the same target
- Manual rules conflict with generated ones
Solution:
- Use
# gazelle:excludeto prevent generation in specific directories - Use
# keepcomment to preserve manual rules:# keepmy_custom_library(name = "custom",...) - Delete conflicting generated rules and re-run
Incremental mode not working
Symptom: --incremental flag doesn’t speed up updates.
Causes:
- No previous state exists
- State was invalidated
- Config changes detected
Solution:
# First run creates statebazelle update
# Check state existsls -la .bazelle/
# If missing, run full update firstbazelle update --forceWatch mode stops responding
Symptom: bazelle watch stops detecting changes.
Causes:
- File system watcher limit reached
- Process backgrounded incorrectly
Solution:
macOS has generous file watcher limits. Try restarting the command.
Increase inotify limit:
# Temporarysudo sysctl fs.inotify.max_user_watches=524288
# Permanent (add to /etc/sysctl.conf)fs.inotify.max_user_watches=524288Daemon not starting
Symptom: bazelle daemon start fails or daemon crashes immediately.
Causes:
- Stale PID/socket files from previous crash
- Socket directory doesn’t exist
- Permission issues
Solution:
- Clean up stale files:
Terminal window rm -f ~/.bazelle/daemon.sock ~/.bazelle/daemon.pid - Run in foreground to see errors:
Terminal window bazelle daemon start --foreground - Check permissions on
~/.bazelle/directory
Daemon connection refused
Symptom: VS Code or CLI can’t connect to running daemon.
Causes:
- Daemon crashed but PID file still exists
- Socket file permissions incorrect
- Wrong socket path configured
Solution:
- Check daemon status:
Terminal window bazelle daemon status - If it shows “stale PID file”, clean up:
Terminal window bazelle daemon start # Auto-cleans stale files - Verify socket permissions (should be 0600):
Terminal window ls -la ~/.bazelle/daemon.sock - Check VS Code is using correct socket path in settings
Daemon using too much memory
Symptom: Daemon process grows in memory over time.
Causes:
- Watching too many files
- Memory leak (rare)
Solution:
- Restart the daemon periodically:
Terminal window bazelle daemon restart - Use
.gitignorepatterns to exclude unnecessary files - Watch only specific subdirectories:
Terminal window # In VS Code or via daemon API, specify pathsbazelle watch ./src # Instead of entire workspace
Wrong dependencies generated
Symptom: Generated deps attribute has incorrect targets.
Causes:
- Import statements not recognized
- External dependencies not configured
- Resolver can’t find matching target
Solution:
- Check import statements are valid
- For external deps, verify
MODULE.bazelconfiguration - Use
# gazelle:resolvedirective to fix specific imports:# gazelle:resolve py my.package //third_party:my_package - Run with verbose logging to see resolution:
Terminal window bazelle -v 3 update
Pre-commit hooks failing
Symptom: bazelle update --check fails in CI/pre-commit.
Causes:
- BUILD files are out of sync with source
- Different Bazelle version in CI
Solution:
- Run
bazelle updatelocally and commit changes - Ensure CI uses the same Bazelle version
- Consider adding to pre-commit:
.pre-commit-config.yaml - repo: localhooks:- id: bazellename: Update BUILD filesentry: bazelle updatelanguage: systempass_filenames: false
Debug Logging
Enable detailed logging to diagnose issues:
# Verbosity levelsbazelle -v 0 update # Errors onlybazelle -v 1 update # Warnings (default)bazelle -v 2 update # Infobazelle -v 3 update # Debugbazelle -v 4 update # Trace
# JSON output for parsingbazelle --log-format json update 2>debug.jsonGetting Help
If you can’t resolve an issue:
- Search existing issues
- Create a new issue with:
- Bazelle version (
bazelle version) - Bazel version (
bazel version) - Minimal reproduction steps
- Debug logs (
bazelle -v 3 update)
- Bazelle version (