From 177124a87d176caa9ceddb15f4c55ed5af4ea37b Mon Sep 17 00:00:00 2001 From: Alex Rodionov Date: Sun, 1 Mar 2026 09:30:41 -0800 Subject: [PATCH 1/2] chore(deps): upgrade bazel to v9 --- .bazelversion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.bazelversion b/.bazelversion index acd405b1d..f7ee06693 100644 --- a/.bazelversion +++ b/.bazelversion @@ -1 +1 @@ -8.6.0 +9.0.0 From a9e5ad1c97f3455b503231f6840c9cc6ebb71beb Mon Sep 17 00:00:00 2001 From: Alex Rodionov Date: Sun, 1 Mar 2026 09:31:31 -0800 Subject: [PATCH 2/2] feat: drop WORKSPACE mode --- .github/workflows/ci.yml | 15 ++----- README.md | 36 +--------------- WORKSPACE | 0 docs/repository_rules.md | 6 +-- examples/deep_gem/.bazelrc | 4 ++ examples/gem/.bazelrc | 4 ++ examples/gem/WORKSPACE | 81 ----------------------------------- examples/gem/WORKSPACE.bzlmod | 2 - examples/proto/.bazelrc | 6 ++- examples/rails/.bazelrc | 7 +-- 10 files changed, 25 insertions(+), 136 deletions(-) delete mode 100644 WORKSPACE delete mode 100644 examples/gem/WORKSPACE delete mode 100644 examples/gem/WORKSPACE.bzlmod diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a22d50ad..9113e2291 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,9 +47,6 @@ jobs: - ubuntu-latest - macos-latest - windows-latest - mode: - - bzlmod - - WORKSPACE exclude: # TruffleRuby doesn't work on Windows. - os: windows-latest @@ -61,8 +58,7 @@ jobs: - uses: actions/checkout@v6 - uses: bazel-contrib/setup-bazel@0.18.0 with: - # Move autoload_externally to .bazelrc once Bazel 6 support is dropped. - bazelrc: common --announce_rc --color=yes --incompatible_autoload_externally= ${{ matrix.mode == 'WORKSPACE' && '--enable_workspace' || '' }} + bazelrc: common --announce_rc --color=yes module-root: examples/gem # Workaround for long path issues: https://github.com/jruby/jruby/issues/3995. output-base: ${{ matrix.os == 'windows-latest' && 'D:/b' || '' }} @@ -160,8 +156,7 @@ jobs: - uses: actions/checkout@v6 - uses: bazel-contrib/setup-bazel@0.18.0 with: - # Move autoload_externally to .bazelrc once Bazel 6 support is dropped. - bazelrc: common --announce_rc --color=yes --incompatible_autoload_externally= + bazelrc: common --announce_rc --color=yes module-root: examples/deep_gem # Workaround for long path issues: https://github.com/jruby/jruby/issues/3995. output-base: ${{ matrix.os == 'windows-latest' && 'D:/b' || '' }} @@ -193,8 +188,7 @@ jobs: - uses: actions/checkout@v6 - uses: bazel-contrib/setup-bazel@0.18.0 with: - # Move autoload_externally to .bazelrc once Bazel 6 support is dropped. - bazelrc: common --announce_rc --incompatible_autoload_externally= + bazelrc: common --announce_rc module-root: examples/rails repository-cache: true - run: echo ${{ matrix.ruby }} > .ruby-version @@ -225,8 +219,7 @@ jobs: - uses: actions/checkout@v6 - uses: bazel-contrib/setup-bazel@0.15.0 with: - # Move autoload_externally to .bazelrc once Bazel 6 support is dropped. - bazelrc: common --announce_rc --incompatible_autoload_externally= + bazelrc: common --announce_rc module-root: examples/proto repository-cache: true - run: echo ${{ matrix.ruby }} > .ruby-version diff --git a/README.md b/README.md index 0e4ea7ffa..b45334d61 100755 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ This repository hosts [Ruby][1] language ruleset for [Bazel][2]. The ruleset is known to work with: -- Bazel 8 using WORKSPACE and Bzlmod _(tested on CI)_. +- Bazel 9 using Bzlmod _(tested on CI)_. +- Bazel 8 using WORKSPACE and Bzlmod _(no longer tested on CI)_. - Bazel 7 using WORKSPACE and Bzlmod _(no longer tested on CI)_. ## Getting Started @@ -15,39 +16,6 @@ The ruleset is known to work with: The fastest way to try this in an empty project is to click the green "Use this template" button on https://github.com/bazel-starters/ruby. -### WORKSPACE - -1. Install the ruleset following WORKSPACE instructions on the [latest release][13]. -2. Download and install Ruby: - -```bazel -# WORKSPACE -load("@rules_ruby//ruby:deps.bzl", "rb_register_toolchains") - -rb_register_toolchains( - version = "3.3.9", - # alternatively, load version from .ruby-version file - # version_file = "//:.ruby-version", -) -``` - -3. _(Optional)_ Download and install Bundler dependencies: - -```bazel -# WORKSPACE -load("@rules_ruby//ruby:deps.bzl", "rb_bundle_fetch") - -rb_bundle_fetch( - name = "bundle", - gemfile = "//:Gemfile", - gemfile_lock = "//:Gemfile.lock", -) -``` - -4. Start defining your library, binary and test targets in `BUILD` files. - -### Bzlmod - 1. Install ruleset following Bzlmod instructions on the [latest release][13]. 2. Download and install Ruby: diff --git a/WORKSPACE b/WORKSPACE deleted file mode 100644 index e69de29bb..000000000 diff --git a/docs/repository_rules.md b/docs/repository_rules.md index 9f1c8e223..dde6d37c9 100644 --- a/docs/repository_rules.md +++ b/docs/repository_rules.md @@ -100,7 +100,7 @@ rb_library( load("@rules_ruby//ruby:deps.bzl", "rb_bundle_fetch") rb_bundle_fetch(name, srcs, auth_patterns, bundler_checksums, bundler_remote, env, gem_checksums, - gemfile, gemfile_lock, jar_checksums, netrc, repo_mapping, ruby) + gemfile, gemfile_lock, jar_checksums, netrc, ruby) Fetches Bundler dependencies to be automatically installed by other targets. @@ -171,7 +171,6 @@ rb_test( | gemfile_lock | Gemfile.lock to install dependencies from. | Label | required | | | jar_checksums | SHA-256 checksums for JAR dependencies. Keys are Maven coordinates (e.g. org.yaml:snakeyaml:1.33), values are SHA-256 checksums. | Dictionary: String -> String | optional | `{}` | | netrc | Path to .netrc file to read credentials from | String | optional | `""` | -| repo_mapping | In `WORKSPACE` context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.

For example, an entry `"@foo": "@bar"` declares that, for any time this repository depends on `@foo` (such as a dependency on `@foo//some:target`, it should actually resolve that dependency within globally-declared `@bar` (`@bar//some:target`).

This attribute is _not_ supported in `MODULE.bazel` context (when invoking a repository rule inside a module extension's implementation function). | Dictionary: String -> String | optional | | | ruby | Override Ruby toolchain to use for installation. | Label | optional | `None` | @@ -182,7 +181,7 @@ rb_test(
 load("@rules_ruby//ruby:deps.bzl", "rb_bundle_rule")
 
-rb_bundle_rule(name, srcs, env, gemfile, repo_mapping, toolchain)
+rb_bundle_rule(name, srcs, env, gemfile, toolchain)
 
(Deprecated) Use `rb_bundle_fetch()` instead. @@ -229,7 +228,6 @@ rb_binary( | srcs | List of Ruby source files used to build the library. | List of labels | optional | `[]` | | env | Environment variables to use during installation. | Dictionary: String -> String | optional | `{}` | | gemfile | Gemfile to install dependencies from. | Label | optional | `None` | -| repo_mapping | In `WORKSPACE` context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.

For example, an entry `"@foo": "@bar"` declares that, for any time this repository depends on `@foo` (such as a dependency on `@foo//some:target`, it should actually resolve that dependency within globally-declared `@bar` (`@bar//some:target`).

This attribute is _not_ supported in `MODULE.bazel` context (when invoking a repository rule inside a module extension's implementation function). | Dictionary: String -> String | optional | | | toolchain | - | Label | required | | diff --git a/examples/deep_gem/.bazelrc b/examples/deep_gem/.bazelrc index de04e6adb..06c880e42 100644 --- a/examples/deep_gem/.bazelrc +++ b/examples/deep_gem/.bazelrc @@ -15,6 +15,10 @@ startup --windows_enable_symlinks build --enable_runfiles +# Do not autoload language-specific rules removed in Bazel core. +# https://github.com/bazelbuild/bazel/issues/23043 +common --incompatible_autoload_externally= + # Allow to run Bazel without pre-installed JDK. # Docs: https://bazel.build/reference/command-line-reference#flag--java_runtime_version build --java_runtime_version=remotejdk_21 --tool_java_runtime_version=remotejdk_21 diff --git a/examples/gem/.bazelrc b/examples/gem/.bazelrc index de04e6adb..06c880e42 100644 --- a/examples/gem/.bazelrc +++ b/examples/gem/.bazelrc @@ -15,6 +15,10 @@ startup --windows_enable_symlinks build --enable_runfiles +# Do not autoload language-specific rules removed in Bazel core. +# https://github.com/bazelbuild/bazel/issues/23043 +common --incompatible_autoload_externally= + # Allow to run Bazel without pre-installed JDK. # Docs: https://bazel.build/reference/command-line-reference#flag--java_runtime_version build --java_runtime_version=remotejdk_21 --tool_java_runtime_version=remotejdk_21 diff --git a/examples/gem/WORKSPACE b/examples/gem/WORKSPACE deleted file mode 100644 index 893ba9eb0..000000000 --- a/examples/gem/WORKSPACE +++ /dev/null @@ -1,81 +0,0 @@ -local_repository( - name = "rules_ruby", - path = "../..", -) - -load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") - -http_archive( - name = "bazel_skylib", - sha256 = "66ffd9315665bfaafc96b52278f57c7e2dd09f5ede279ea6d39b2be471e7e3aa", - urls = [ - "https://github.com/bazelbuild/bazel-skylib/releases/download/1.4.2/bazel-skylib-1.4.2.tar.gz", - ], -) - -load("@rules_ruby//ruby:deps.bzl", "rb_bundle_fetch", "rb_register_toolchains") - -rb_register_toolchains( - portable_ruby = True, - version_file = "//:.ruby-version", -) - -rb_bundle_fetch( - name = "bundle", - srcs = [ - "//:gem.gemspec", - "//:lib/gem/version.rb", - ], - env = { - "BUNDLE_BUILD__FOO": "bar", - }, - gem_checksums = { - "ast-2.4.2": "1e280232e6a33754cde542bc5ef85520b74db2aac73ec14acef453784447cc12", - "concurrent-ruby-1.3.5": "813b3e37aca6df2a21a3b9f1d497f8cbab24a2b94cab325bffe65ee0f6cbebc6", - "debug-1.10.0": "11e28ca74875979e612444104f3972bd5ffb9e79179907d7ad46dba44bd2e7a4", - "diff-lcs-1.5.1": "273223dfb40685548436d32b4733aa67351769c7dea621da7d9dd4813e63ddfe", - "docker-api-2.4.0": "824be734f4cc8718189be9c8e795b6414acbbf7e8b082a06f959a27dd8dd63e6", - "excon-1.3.2": "a089babe98638e58042a7d542b2bbd183304527e33d612b6dde22fa491a544a5", - "i18n-1.14.7": "ceba573f8138ff2c0915427f1fc5bdf4aa3ab8ae88c8ce255eb3ecf0a11a5d0f", - "io-console-0.8.0": "cd6a9facbc69871d69b2cb8b926fc6ea7ef06f06e505e81a64f14a470fddefa2", - "io-console-0.8.0-java": "3cc6fd5c66e587145c1fdf8dc40c2e3d851e90722a5d0cc3f38da352f06fe1bd", - "irb-1.15.1": "d9bca745ac4207a8b728a52b98b766ca909b86ff1a504bcde3d6f8c84faae890", - "jar-dependencies-0.5.3": "f6a7a0bf3f917252461e2a87f9f54005424502f7dc9ef912d8b9540658dbd0bc", - "json-2.9.1": "d2bdef4644052fad91c1785d48263756fe32fcac08b96a20bb15840e96550d11", - "json-2.9.1-java": "88de8c79b54fee6ae1b4854bc48b8d7089f524cbacaf4596df24f86b10896ee8", - "language_server-protocol-3.17.0.3": "3d5c58c02f44a20d972957a9febe386d7e7468ab3900ce6bd2b563dd910c6b3f", - "logger-1.7.0": "196edec7cc44b66cfb40f9755ce11b392f21f7967696af15d274dde7edff0203", - "multi_json-1.19.1": "7aefeff8f2c854bf739931a238e4aea64592845e0c0395c8a7d2eea7fdd631b7", - "parallel-1.26.3": "d86babb7a2b814be9f4b81587bf0b6ce2da7d45969fab24d8ae4bf2bb4d4c7ef", - "parser-3.3.7.0": "7449011771e3e7881297859b849de26a6f4fccd515bece9520a87e7d2116119b", - "pp-0.6.2": "947ec3120c6f92195f8ee8aa25a7b2c5297bb106d83b41baa02983686577b6ff", - "prettyprint-0.2.0": "2bc9e15581a94742064a3cc8b0fb9d45aae3d03a1baa6ef80922627a0766f193", - "psych-5.0.1": "43264252cc33b8e626fb940cddc7379d00f7583500680da32c74a54bd9b000d0", - "psych-5.0.1-java": "c4a94895e325d326063f9d53f5e4f231a5df3a6e593ce9563d19b35fe11f800d", - "racc-1.8.1": "4a7f6929691dbec8b5209a0b373bc2614882b55fc5d2e447a21aaa691303d62f", - "racc-1.8.1-java": "54f2e6d1e1b91c154013277d986f52a90e5ececbe91465d29172e49342732b98", - "rainbow-3.1.1": "039491aa3a89f42efa1d6dec2fc4e62ede96eb6acd95e52f1ad581182b79bc6a", - "rake-13.2.1": "46cb38dae65d7d74b6020a4ac9d48afed8eb8149c040eccf0523bec91907059d", - "rdoc-6.11.0": "bec66fb9b019be64f7ba7d2cd2aecb283a3a01fef23a95b33e2349c6d1aa0040", - "regexp_parser-2.10.0": "cb6f0ddde88772cd64bff1dbbf68df66d376043fe2e66a9ef77fcb1b0c548c61", - "reline-0.6.0": "57620375dcbe56ec09bac7192bfb7460c716bbf0054dc94345ecaa5438e539d2", - "rspec-3.13.0": "d490914ac1d5a5a64a0e1400c1d54ddd2a501324d703b8cfe83f458337bab993", - "rspec-core-3.13.2": "94fbda6e4738e478f1c7532b7cc241272fcdc8b9eac03a97338b1122e4573300", - "rspec-expectations-3.13.3": "0e6b5af59b900147698ea0ff80456c4f2e69cac4394fbd392fbd1ca561f66c58", - "rspec-mocks-3.13.2": "2327335def0e1665325a9b617e3af9ae20272741d80ac550336309a7c59abdef", - "rspec-support-3.13.2": "cea3a2463fd9b84b9dcc9685efd80ea701aa8f7b3decb3b3ce795ed67737dbec", - "rubocop-1.71.0": "e19679efd447346ac476122313d3788ae23c38214790bcf660e984c747608bf0", - "rubocop-ast-1.37.0": "9513ac88aaf113d04b52912533ffe46475de1362d4aa41141b51b2455827c080", - "ruby-progressbar-1.13.0": "80fc9c47a9b640d6834e0dc7b3c94c9df37f08cb072b7761e4a71e22cff29b33", - "stringio-3.2.0": "c37cb2e58b4ffbd33fe5cd948c05934af997b36e0b6ca6fdf43afa234cf222e1", - "testcontainers-0.2.0": "b8fb466cfbba02eef9120fa0f4e1ebce6c7220b65c5b025ce003d8c6a6b68c67", - "testcontainers-core-0.2.0": "94f316f08f388a8afb75a4fec6ff9ed4289cf60ca7a77522d4ca26688f4c4da4", - "unicode-display_width-3.1.4": "8caf2af1c0f2f07ec89ef9e18c7d88c2790e217c482bfc78aaa65eadd5415ac1", - "unicode-emoji-4.2.0": "519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f", - }, - gemfile = "//:Gemfile", - gemfile_lock = "//:Gemfile.lock", - jar_checksums = { - "org.yaml:snakeyaml:1.33": "11ff459788f0a2d781f56a4a86d7e69202cebacd0273d5269c4ae9f02f3fd8f0", - }, -) diff --git a/examples/gem/WORKSPACE.bzlmod b/examples/gem/WORKSPACE.bzlmod deleted file mode 100644 index fb54e76a9..000000000 --- a/examples/gem/WORKSPACE.bzlmod +++ /dev/null @@ -1,2 +0,0 @@ -# Marker file that this is the root of a Bazel workspace. -# This file replaces WORKSPACE.bazel under --enable_bzlmod. diff --git a/examples/proto/.bazelrc b/examples/proto/.bazelrc index f118a03ed..777d129e2 100644 --- a/examples/proto/.bazelrc +++ b/examples/proto/.bazelrc @@ -1,2 +1,6 @@ common --@protobuf//bazel/toolchains:prefer_prebuilt_protoc -common --repo_env="JAVA_HOME=../bazel_tools/jdk" \ No newline at end of file +common --repo_env="JAVA_HOME=../bazel_tools/jdk" + +# Do not autoload language-specific rules removed in Bazel core. +# https://github.com/bazelbuild/bazel/issues/23043 +common --incompatible_autoload_externally= diff --git a/examples/rails/.bazelrc b/examples/rails/.bazelrc index 8b1a85ff5..09db6ba8d 100644 --- a/examples/rails/.bazelrc +++ b/examples/rails/.bazelrc @@ -10,8 +10,9 @@ build --incompatible_strict_action_env=true # Don't allow empty glob patterns by default build --incompatible_disallow_empty_glob -# Enable bzlmod -common --enable_bzlmod - # Download the JDK to run Bazel build --java_runtime_version=remotejdk_11 + +# Do not autoload language-specific rules removed in Bazel core. +# https://github.com/bazelbuild/bazel/issues/23043 +common --incompatible_autoload_externally=