Skip to content

Bump dependency versions for rules_scala v7.1.0 #1755

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mbland
Copy link
Contributor

@mbland mbland commented Jul 24, 2025

Description

Bumps most dependency versions (except rules_python under WORKSPACE) to the latest available before releasing rules_scala v7.1.0. Also bumps the rules_scala version number in MODULE.bazel to 7.1.0.

  • Go: 1.24.4 => 1.24.5
  • Scalafmt: 3.9.7 => 3.9.8
  • bazel_skylib: 1.7.1 => 1.8.1
  • gazelle: 0.43.0 => 0.44.0
  • golang.org/x/tools: v0.34.0 => v0.35.0
  • org.scala-sbt:util-interface: 1.11.1 => 1.11.3
  • proto-google-common-protos: 2.58.0 => 2.59.2
  • rules_cc: 0.1.1 => 0.1.4
  • rules_go: 0.55.0 => 0.55.1
  • rules_java: 8.12.0 => 8.14.0
  • rules_jvm_external: 6.7 => 6.8
  • rules_python: 1.4.1 => 1.5.1 (Bzlmod only)

Also:

  • Moves the http_archive instantiations of rules_python and rules_shell from individual WORKSPACE files to //scala:latest_deps.bzl. Removes load statements for http_archive throughout all WORKSPACE files.

  • Removes the --incompatible_autoload_externally flag from .bazelrc.

  • Fixes _get_compiler_srcjar from //scala/private:macros/scala_repositories.bzl to return empty compiler_srcjar_objects instead of returning a valid object. Caught by test_compiler_srcjar_error 2.12.11 from dt_patches/dt_patch_test.sh when testing under WORKSPACE. Added test_fail_if_compiler_srcjar_object_is_empty to test/shell/test_compiler_sources_integrity.sh to catch the specific problem sooner.

Motivation

This is to ensure that we're compatible with the latest dependencies available before releasing a new minor version.

I moved the rules_python instantiation to //scala:latest_deps.bzl because it was such a pain to update everywhere. latest_deps.bzl is essentially a development file, or a "use at your own risk" file, and the primary consumers are internal test modules. This will make future rules_python updates less noisy.

The only rules_shell instantiations were in the top level WORKSPACE and test_version/WORKSPACE.template. I moved rules_shell into latest_deps.bzl to eliminate these direct instantations as well, and to remove the http_archive imports from those files.

I'd added --incompatible_autoload_externally in #1748 when fixing problems with WORKSPACE builds under Bazel 8.2.1. However, it's not really necessary, so I removed it.

Updating rules_python from 1.4.1 to 1.5.1 produced the following error in Bazel 7.6.1 WORKSPACE builds, even with
--incompatible_autoload_externally=+@rules_python:

$ bazel build //src/... //test/...

WARNING: Couldn't auto load rules or symbols, because no dependency on
  module/repository 'rules_python' found. This will result in a failure
  if there's a reference to those rules or symbols.

ERROR: test/BUILD:824:10: in py_binary rule //test:py_resource_binary:
Traceback (most recent call last):
  File ".../external/rules_python/python/private/py_binary_rule.bzl",
    line 24, column 30, in _py_binary_impl
      return py_executable_impl(
  File ".../external/rules_python/python/private/py_executable.bzl",
    line 255, column 35, in py_executable_impl
      py_executable_base_impl(
  File ".../external/rules_python/python/private/py_executable.bzl",
    line 1140, column 46, in py_executable_base_impl
      exec_result = semantics.create_executable(
  File ".../external/rules_python/python/private/py_executable.bzl",
    line 365, column 33, in _create_executable
      _create_stage1_bootstrap(
  File ".../external/rules_python/python/private/py_executable.bzl",
    line 809, column 27, in _create_stage1_bootstrap
      if runtime and runtime.supports_build_time_venv:

Error: 'PyRuntimeInfo' value has no field or method
  'supports_build_time_venv'
Available attributes: bootstrap_template, coverage_files, coverage_tool,
  files, interpreter, interpreter_path, python_version, stub_shebang

ERROR: test/BUILD:824:10: Analysis of target
  '//test:py_resource_binary' failed
ERROR: Analysis of target '//test:py_resource_binary' failed;
  build aborted

This is due to bazel-contrib/rules_python#2760. In contrast, Bazel 8.3.1 builds work fine, as do Bazel 7.6.1 builds under Bzlmod.

Trying --incompatible_autoload_externally=PyRuntimeInfo to work around the problem under Bazel 7.6.1 produced:

$ bazel build //src/... //test/...

FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.IllegalStateException: Symbol in 'PyRuntimeInfo' can't be
  removed, because it's still used by: py_binary, py_test, py_library
    at com.google.devtools.build.lib.packages.AutoloadSymbols.<init>(AutoloadSymbols.java:192)
    [...snip...]

And with --incompatible_autoload_externally=@rules_python produced:

WARNING: Couldn't auto load rules or symbols, because no dependency on
  module/repository 'rules_python' found. This will result in a failure
  if there's a reference to those rules or symbols.

ERROR: .../external/bazel_tools/tools/python/toolchain.bzl:25:44:
  name 'PyRuntimeInfo' is not defined
ERROR: .../external/bazel_tools/tools/python/toolchain.bzl:33:44:
  name 'PyRuntimeInfo' is not defined
ERROR: .../external/bazel_tools/tools/python/toolchain.bzl:64:26:
  name 'PyRuntimeInfo' is not defined
ERROR: .../external/bazel_tools/tools/python/toolchain.bzl:72:26:
  name 'PyRuntimeInfo' is not defined

WARNING: Target pattern parsing failed.
ERROR: Skipping '//test/...':
  error loading package under directory 'test':
  error loading package 'test':
  at .../external/rules_python/python/defs.bzl:21:6:
  at .../external/rules_python/python/py_runtime_pair.bzl:17:6:
  compilation of module 'tools/python/toolchain.bzl' failed

ERROR: error loading package under directory 'test':
  error loading package 'test':
  at .../external/rules_python/python/defs.bzl:21:6:
  at .../external/rules_python/python/py_runtime_pair.bzl:17:6:
  compilation of module 'tools/python/toolchain.bzl' failed

tools/python/toolchain.bzl from Bazel 7.6.1 breaks because it references the builtin PyRuntimeInfo instead of loading it from @rules_python. Bazel 8 replaces that file's entire implementation with a function that fails with a deprecation error and doesn't use PyRuntimeInfo:

Using +@rules_python or +PyRuntimeInfo produced the original error. Nothing I could do could avoid using the builtin PyRuntimeInfo under Bazel 7.6.1.

Since it's only a development dependency for WORKSPACE builds, I decided to keep rules_python at 1.4.1 in latest_deps.bzl for now. I've filed bazel-contrib/rules_python#3119 to get it on the record.

Bumps most dependency versions (except `rules_python` under `WORKSPACE`)
to the latest available before releasing `rules_scala` v7.1.0. Also
bumps the `rules_scala` version number in `MODULE.bazel` to `7.1.0`.

- Go: 1.24.4 => 1.24.5
- Scalafmt: 3.9.7 => 3.9.8
- `bazel_skylib`: 1.7.1 => 1.8.1
- `gazelle`: 0.43.0 => 0.44.0
- `golang.org/x/tools`: v0.34.0 => v0.35.0
- `org.scala-sbt:util-interface`: 1.11.1 => 1.11.3
- `proto-google-common-protos`: 2.58.0 => 2.59.2
- `rules_cc`: 0.1.1 => 0.1.4
- `rules_go`: 0.55.0 => 0.55.1
- `rules_java`: 8.12.0 => 8.14.0
- `rules_jvm_external`: 6.7 => 6.8
- `rules_python`: 1.4.1 => 1.5.1 (Bzlmod only)

Also:

- Moves the `http_archive` instantiations of `rules_python` and
  `rules_shell` from individual `WORKSPACE` files to
  `//scala:latest_deps.bzl`. Removes `load` statements for
  `http_archive` throughout all `WORKSPACE` files.

- Removes the `--incompatible_autoload_externally` flag from `.bazelrc`.

- Fixes `_get_compiler_srcjar` from
  `//scala/private:macros/scala_repositories.bzl` to return empty
  `compiler_srcjar_objects` instead of returning a valid object.
  Caught by `test_compiler_srcjar_error 2.12.11` from
  `dt_patches/dt_patch_test.sh` when testing under `WORKSPACE`.
  Added `test_fail_if_compiler_srcjar_object_is_empty` to
  `test/shell/test_compiler_sources_integrity.sh` to catch the specific
  problem sooner.

---

This is to ensure that we're compatible with the latest dependencies
available before releasing a new minor version.

I moved the `rules_python` instantiation to `//scala:latest_deps.bzl`
because it was such a pain to update everywhere. `latest_deps.bzl` is
essentially a development file, or a "use at your own risk" file, and
the primary consumers are internal test modules. This will make future
`rules_python` updates less noisy.

The only `rules_shell` instantiations were in the top level `WORKSPACE`
and `test_version/WORKSPACE.template`. I moved `rules_shell` into
`latest_deps.bzl` to eliminate these direct instantations as well, and
to remove the `http_archive` imports from those files.

I'd added `--incompatible_autoload_externally` in bazel-contrib#1748 when fixing
problems with `WORKSPACE` builds under Bazel 8.2.1. However, it's not
really necessary, so I removed it.

Updating `rules_python` from 1.4.1 to 1.5.1 produced the following error
in Bazel 7.6.1 WORKSPACE builds, even with
`--incompatible_autoload_externally=+@rules_python`:

```txt
$ bazel build //src/... //test/...

WARNING: Couldn't auto load rules or symbols, because no dependency on
  module/repository 'rules_python' found. This will result in a failure
  if there's a reference to those rules or symbols.

ERROR: test/BUILD:824:10: in py_binary rule //test:py_resource_binary:
Traceback (most recent call last):
  File ".../external/rules_python/python/private/py_binary_rule.bzl",
    line 24, column 30, in _py_binary_impl
      return py_executable_impl(
  File ".../external/rules_python/python/private/py_executable.bzl",
    line 255, column 35, in py_executable_impl
      py_executable_base_impl(
  File ".../external/rules_python/python/private/py_executable.bzl",
    line 1140, column 46, in py_executable_base_impl
      exec_result = semantics.create_executable(
  File ".../external/rules_python/python/private/py_executable.bzl",
    line 365, column 33, in _create_executable
      _create_stage1_bootstrap(
  File ".../external/rules_python/python/private/py_executable.bzl",
    line 809, column 27, in _create_stage1_bootstrap
      if runtime and runtime.supports_build_time_venv:

Error: 'PyRuntimeInfo' value has no field or method
  'supports_build_time_venv'
Available attributes: bootstrap_template, coverage_files, coverage_tool,
  files, interpreter, interpreter_path, python_version, stub_shebang

ERROR: test/BUILD:824:10: Analysis of target
  '//test:py_resource_binary' failed
ERROR: Analysis of target '//test:py_resource_binary' failed;
  build aborted
```

This is due to bazel-contrib/rules_python#2760. In contrast, Bazel 8.3.1
builds work fine, as do Bazel 7.6.1 builds under Bzlmod.

Trying `--incompatible_autoload_externally=PyRuntimeInfo` to work around
the problem under Bazel 7.6.1 produced:

```txt
$ bazel build //src/... //test/...

FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.IllegalStateException: Symbol in 'PyRuntimeInfo' can't be
  removed, because it's still used by: py_binary, py_test, py_library
    at com.google.devtools.build.lib.packages.AutoloadSymbols.<init>(AutoloadSymbols.java:192)
    [...snip...]
```

And with `--incompatible_autoload_externally=@rules_python` produced:

```txt
WARNING: Couldn't auto load rules or symbols, because no dependency on
  module/repository 'rules_python' found. This will result in a failure
  if there's a reference to those rules or symbols.

ERROR: .../external/bazel_tools/tools/python/toolchain.bzl:25:44:
  name 'PyRuntimeInfo' is not defined
ERROR: .../external/bazel_tools/tools/python/toolchain.bzl:33:44:
  name 'PyRuntimeInfo' is not defined
ERROR: .../external/bazel_tools/tools/python/toolchain.bzl:64:26:
  name 'PyRuntimeInfo' is not defined
ERROR: .../external/bazel_tools/tools/python/toolchain.bzl:72:26:
  name 'PyRuntimeInfo' is not defined

WARNING: Target pattern parsing failed.
ERROR: Skipping '//test/...':
  error loading package under directory 'test':
  error loading package 'test':
  at .../external/rules_python/python/defs.bzl:21:6:
  at .../external/rules_python/python/py_runtime_pair.bzl:17:6:
  compilation of module 'tools/python/toolchain.bzl' failed

ERROR: error loading package under directory 'test':
  error loading package 'test':
  at .../external/rules_python/python/defs.bzl:21:6:
  at .../external/rules_python/python/py_runtime_pair.bzl:17:6:
  compilation of module 'tools/python/toolchain.bzl' failed
```

`tools/python/toolchain.bzl` from Bazel 7.6.1 breaks because it
references the builtin `PyRuntimeInfo` instead of `load`ing it from
`@rules_python`. Bazel 8 replaces that file's entire implementation with
a function that `fail`s with a deprecation error and doesn't use
`PyRuntimeInfo`:

- https://github.com/bazelbuild/bazel/blob/7.6.1/tools/python/toolchain.bzl
- https://github.com/bazelbuild/bazel/blob/8.0.0/tools/python/toolchain.bzl

Using `+@rules_python` or `+PyRuntimeInfo` produced the original error.
Nothing I could do could avoid using the builtin `PyRuntimeInfo` under
Bazel 7.6.1.

Since it's only a development dependency for `WORKSPACE` builds, I
decided to keep `rules_python` at 1.4.1 in `latest_deps.bzl` for now.
I've filed bazel-contrib/rules_python#3119 to get it on the record.
@mbland mbland requested review from liucijus and simuons as code owners July 24, 2025 22:50
The unescaped `{` in the expected failure message caused
`test_fail_if_compiler_srcjar_object_is_empty` to fail on Linux and
Windows. Rather than escape it, it works just as well to remove it
entirely.

See also the "Escape '{', '}' in `test/shell/test_bzlmod_macros`"
message from bazel-contrib#1722 and commit 3f37e26.
@mbland
Copy link
Contributor Author

mbland commented Jul 24, 2025

P.S. I tested this under Bzlmod and WORKSPACE with both Bazel 7.6.1 and 8.3.1.

I also tested it under Bzlmod with Bazel 9.0.0-pre.20250710.1. Per my comments in #1754, this is the latest Bazel pre-release that will work until a fix lands for bazelbuild/bazel#26579.

This is temporary until a fix lands for bazelbuild/bazel#26579, but will
ensure that new changes get some degree of prerelease testing.
@mbland
Copy link
Contributor Author

mbland commented Jul 24, 2025

P.P.S. I just added a non-optional CI job for Bazel 9.0.0-pre.20250710.1 to ensure incoming changes get some prerelease coverage before a fix lands for bazelbuild/bazel#26579. I'm happy to revert it if you prefer, though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant