Skip to content

Commit 6f3840e

Browse files
authored
Add load statements after disabling autoloads (#391)
Explicitly loads all symbols affected by `--incompatible_disable_autoloads_in_main_repo` to fix `last_green` Bazel builds. Adds the flag to `.bazelrc`, adds `rules_shell` as a dependency, and contains lots of other Buildifier formatting touch ups. bazelbuild/bazel@d87eaf5 from 2025-05-08 at 8:03am EDT flipped `--incompatible_disable_autoloads_in_main_repo` to `true` to prepare for Bazel 9. See also bazel-contrib/rules_scala#1738. Before this change, setting the flag caused these errors: ```txt $ bazel build --incompatible_disable_autoloads_in_main_repo //... ERROR: java/com/engflow/notificationqueue/demoserver/BUILD:5:1: name 'proto_library' is not defined ERROR: /demoserver/BUILD:10:1: name 'java_proto_library' is not defined (did you mean 'java_grpc_library'?) ERROR: docker/network/BUILD:19:10: //docker/network:docker-network-test: no such attribute 'srcs' in 'java_test' rule ERROR: docker/network/BUILD:19:10: //docker/network:docker-network-test: no such attribute 'test_class' in 'java_test' rule ERROR: docker/sandbox/BUILD:15:12: //docker/sandbox:hello-java: no such attribute 'srcs' in 'java_binary' rule ERROR: docker/sandbox/BUILD:15:12: //docker/sandbox:hello-java: no such attribute 'main_class' in 'java_binary' rule ERROR: docker/sysbox/dind_test/BUILD:15:1: name 'sh_test' is not defined (did you mean 'cc_test'?) ERROR: package contains errors: docker/sysbox/dind_test ERROR: python/pytest/BUILD:3:1: name 'py_library' is not defined (did you mean 'cc_library'?) ERROR: package contains errors: docker/sandbox ERROR: package contains errors: java/com/engflow/notificationqueue/demoserver ERROR: docker/network/BUILD:39:13: //docker/network:jdk: no such attribute 'java_home' in 'java_runtime' rule ERROR: package contains errors: docker/network ERROR: package contains errors: python/pytest ERROR: java/com/engflow/example/BUILD:3:13: //java/com/engflow/example:example: no such attribute 'srcs' in 'java_library' rule ERROR: java/com/engflow/example/BUILD:8:10: //java/com/engflow/example:ExampleTest: no such attribute 'srcs' in 'java_test' rule ERROR: java/com/engflow/example/BUILD:8:10: //java/com/engflow/example:ExampleTest: no such attribute 'deps' in 'java_test' rule ERROR: package contains errors: java/com/engflow/example ERROR: java/com/engflow/notificationqueue/BUILD:5:12: //java/com/engflow/notificationqueue:client: no such attribute 'srcs' in 'java_binary' rule ERROR: java/com/engflow/notificationqueue/BUILD:5:12: //java/com/engflow/notificationqueue:client: no such attribute 'main_class' in 'java_binary' rule ERROR: java/com/engflow/notificationqueue/BUILD:5:12: //java/com/engflow/notificationqueue:client: no such attribute 'deps' in 'java_binary' rule ERROR: package contains errors: java/com/engflow/notificationqueue WARNING: Target pattern parsing failed. ERROR: Skipping '//...': Error evaluating '//...': error loading package 'docker/network': Package 'docker/network' contains errors ERROR: Error evaluating '//...': error loading package 'docker/network': Package 'docker/network' contains errors INFO: Elapsed time: 2.821s INFO: 0 processes. ERROR: Build did NOT complete successfully ``` Applied the fixes using Buildifier 8.2.0 with the following script: ```bash WARNINGS=( $(buildifier --lint=warn -r . 2>&1 | grep -- native- | awk '{print $2}' | sort | uniq | sed -e 's/:$//') ) IFS=, WARNINGS="${WARNINGS[*]}" echo "warnings: ${WARNINGS}" buildifier --lint=fix --warnings="$WARNINGS" -r . ```
1 parent 0a3ea9d commit 6f3840e

File tree

36 files changed

+167
-111
lines changed

36 files changed

+167
-111
lines changed

.bazelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
common --@aspect_rules_ts//ts:skipLibCheck=honor_tsconfig
33
common --@aspect_rules_ts//ts:default_to_tsc_transpiler
44
common --noincompatible_check_sharding_support
5+
common --incompatible_disable_autoloads_in_main_repo
56

67
# Remove once proto toolchainization becomes the default
78
# - https://bazel.build/reference/command-line-reference#flag--incompatible_enable_proto_toolchain_resolution

MODULE.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,3 +174,5 @@ scala_protoc = use_extension(
174174
dev_dependency = True,
175175
)
176176
use_repo(scala_protoc, "rules_scala_protoc_toolchains")
177+
178+
bazel_dep(name = "rules_shell", version = "0.4.1")

MODULE.bazel.lock

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

buck2/cpp/platforms/defs.bzl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ platforms = rule(
6161
attrs = {
6262
"cpu_configuration": attrs.dep(providers = [ConfigurationInfo]),
6363
"os_configuration": attrs.dep(providers = [ConfigurationInfo]),
64-
},
65-
impl = _platforms
64+
},
65+
impl = _platforms,
6666
)
6767

6868
action_keys = rule(
69-
attrs = {
69+
attrs = {
7070
"cell": attrs.string(),
7171
"mode": attrs.string(),
72-
},
73-
impl = _action_keys
72+
},
73+
impl = _action_keys,
7474
)

buck2/golang/platforms/defs.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ def _action_keys(ctx):
5858

5959
platforms = rule(
6060
attrs = {},
61-
impl = _platforms
61+
impl = _platforms,
6262
)
6363

6464
action_keys = rule(
65-
attrs = {
65+
attrs = {
6666
"cell": attrs.string(),
6767
"mode": attrs.string(),
68-
},
69-
impl = _action_keys
68+
},
69+
impl = _action_keys,
7070
)

buck2/golang/toolchains/defs.bzl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ load("@prelude//go_bootstrap:go_bootstrap.bzl", "GoBootstrapToolchainInfo")
1717
load("@prelude//utils:cmd_script.bzl", "ScriptOs", "cmd_script")
1818

1919
def _remote_go_bootstrap_toolchain_impl(ctx):
20-
go_arch = "amd64"
20+
go_arch = "amd64"
2121
go_os = "linux"
2222

2323
script_os = ScriptOs("unix")
@@ -47,7 +47,7 @@ remote_go_bootstrap_toolchain = rule(
4747
)
4848

4949
def _remote_go_toolchain_impl(ctx):
50-
go_arch = "amd64"
50+
go_arch = "amd64"
5151
go_os = "linux"
5252

5353
script_os = ScriptOs("unix")
@@ -76,7 +76,6 @@ def _remote_go_toolchain_impl(ctx):
7676
compiler_flags = [],
7777
),
7878
]
79-
8079

8180
remote_go_toolchain = rule(
8281
impl = _remote_go_toolchain_impl,

buck2/python/platforms/defs.bzl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ def _action_keys(ctx):
5656

5757
platforms = rule(
5858
attrs = {},
59-
impl = _platforms
59+
impl = _platforms,
6060
)
6161

6262
action_keys = rule(
63-
attrs = {
63+
attrs = {
6464
"cell": attrs.string(),
6565
"mode": attrs.string(),
66-
},
67-
impl = _action_keys
66+
},
67+
impl = _action_keys,
6868
)

buck2/python/toolchains/defs.bzl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ remote_python_toolchain = rule(
5959
"_make_source_db": attrs.default_only(attrs.dep(providers = [RunInfo], default = "prelude//python/tools:make_source_db")),
6060
"_make_source_db_no_deps": attrs.default_only(attrs.dep(providers = [RunInfo], default = "prelude//python/tools:make_source_db_no_deps")),
6161
"_runtime_library": attrs.default_only(attrs.dep(providers = [ArtifactGroupInfo], default = "prelude//python/runtime:bootstrap_files")),
62-
6362
},
6463
is_toolchain_rule = True,
6564
)

buck2/rust/platforms/defs.bzl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ platforms = rule(
6262
attrs = {
6363
"cpu_configuration": attrs.dep(providers = [ConfigurationInfo]),
6464
"os_configuration": attrs.dep(providers = [ConfigurationInfo]),
65-
},
66-
impl = _platforms
65+
},
66+
impl = _platforms,
6767
)
6868

6969
action_keys = rule(
70-
attrs = {
70+
attrs = {
7171
"cell": attrs.string(),
7272
"mode": attrs.string(),
73-
},
74-
impl = _action_keys
73+
},
74+
impl = _action_keys,
7575
)

buck2/rust/toolchains/defs.bzl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
load("@prelude//cxx:cxx_toolchain_types.bzl", "LinkerType")
1516
load("@prelude//rust:rust_toolchain.bzl", "PanicRuntime", "RustToolchainInfo")
1617
load("@prelude//rust/tools:attrs.bzl", "internal_tool_attrs")
17-
load("@prelude//cxx:cxx_toolchain_types.bzl", "LinkerType")
1818
load("@prelude//toolchains:cxx.bzl", "CxxToolsInfo")
1919

2020
# This def is similar to the one in https://github.com/facebook/buck2/blob/804d62242214455d51787f7c8c96a1e12c75ec32/prelude/toolchains/cxx/clang/tools.bzl
@@ -42,7 +42,7 @@ path_clang_tools = rule(
4242
attrs = {},
4343
)
4444

45-
def _remote_rust_toolchain_impl(ctx):
45+
def _remote_rust_toolchain_impl(ctx):
4646
return [
4747
DefaultInfo(),
4848
RustToolchainInfo(

0 commit comments

Comments
 (0)