bazelbuild / bazelbuild/bazel

--incompatible_bazel_external_directory

Open
#30,642 3 comments 2 reactions 0 assignees View on GitHub
incompatible-change team-Configurability team-ExternalDeps
Dominant language
Java
Stars
25.8k
Forks
4.6k
Avg merge
2d 20h
Merged PRs (30d)
72

Description

### Motivation

Previously bazel used an internal `external/` directory in its execroot to compile files from external repos. When using IDE tooling and debuggers, they often need to be able to discover files from this path. This leads users to have to manage an `external/` symlink in the root of their repo if they want these tools to work. With `--incompatible_bazel_external_directory` bazel uses a new `bazel-external` directory instead, and creates a symlink for that in the root of the repo, making IDEs and debuggers work automatically when trying to find something built in these paths.

### Description

When enabled bazel uses `bazel-external` instead of `external` and creates a symlink in the workspace to this path.

### Incompatible Flag

--incompatible_bazel_external_directory

### Migration Guide

- Anything that manually references `external/` needs to be updated to support `bazel-external/` (ideally most uses can support both for backwards compatibility). For example a common pattern in rules is `if path.startswith("external/")`. This can be changed to `if path.startswith(("external/", "bazel-external"))`.
- Uses of `--per_file_copt=external/...` _might_ have to be updated. Note that the regex isn't implicitly anchored to the beginning of the string, so `--per_file_copt=external/` does also match `bazel-external`. Depending on your regexes these might require updating
- Any other places where you manually reference `external/` in rules or CLIs (potentially sidestepping runfiles) will need to be updated. This will likely also mean updating common rulesets past a version that includes a compatibility change for this change.

### In which Bazel LTS version will this incompatible change be enabled?

None

### Additional Context

https://github.com/bazelbuild/bazel/pull/30584

### TODO List

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the behavior described for --incompatible_bazel_external_directory and the context in PR 30584. Search rules and CLIs for manual references to external/ and check the migration-guide cases, including per-file compiler options. Done means affected references support bazel-external/ without breaking external/ compatibility.

Written by the indexing model from the issue text.

Assessment

Domain
build-system, cli
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.