diff --git a/WORKSPACE b/WORKSPACE index 14adaa29357ce..4598c502618f4 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -110,10 +110,12 @@ kt_register_toolchains() http_archive( name = "rules_ruby", urls = [ - "https://github.com/protocolbuffers/rules_ruby/archive/b7f3e9756f3c45527be27bc38840d5a1ba690436.zip" + "https://github.com/protocolbuffers/rules_ruby/archive/4f05aac363689551acb6d13fa015e51352af3960.zip" ], - strip_prefix = "rules_ruby-b7f3e9756f3c45527be27bc38840d5a1ba690436", - sha256 = "347927fd8de6132099fcdc58e8f7eab7bde4eb2fd424546b9cd4f1c6f8f8bad8", + patch_args = ["-p1"], + patches = ["//:rules_ruby.patch"], + strip_prefix = "rules_ruby-4f05aac363689551acb6d13fa015e51352af3960", + sha256 = "ecf2bbdd7fdaccefe5eef68e800f529503f942da3acb2e8a32d96fb2f8e176f2", ) load("@rules_ruby//ruby:defs.bzl", "ruby_runtime") diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod index c0848e5b76939..163803b7836cc 100644 --- a/WORKSPACE.bzlmod +++ b/WORKSPACE.bzlmod @@ -9,10 +9,12 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") http_archive( name = "rules_ruby", urls = [ - "https://github.com/protocolbuffers/rules_ruby/archive/b7f3e9756f3c45527be27bc38840d5a1ba690436.zip" + "https://github.com/protocolbuffers/rules_ruby/archive/4f05aac363689551acb6d13fa015e51352af3960.zip" ], - strip_prefix = "rules_ruby-b7f3e9756f3c45527be27bc38840d5a1ba690436", - sha256 = "347927fd8de6132099fcdc58e8f7eab7bde4eb2fd424546b9cd4f1c6f8f8bad8", + patch_args = ["-p1"], + patches = ["//:rules_ruby.patch"], + strip_prefix = "rules_ruby-4f05aac363689551acb6d13fa015e51352af3960", + sha256 = "ecf2bbdd7fdaccefe5eef68e800f529503f942da3acb2e8a32d96fb2f8e176f2", ) load("@rules_ruby//ruby:defs.bzl", "ruby_runtime") diff --git a/rules_ruby.patch b/rules_ruby.patch new file mode 100644 index 0000000000000..4a8137867e310 --- /dev/null +++ b/rules_ruby.patch @@ -0,0 +1,49 @@ +diff --git a/ruby/private/bundle/create_bundle_build_file.rb b/ruby/private/bundle/create_bundle_build_file.rb +index 0c67128..3b0ac0d 100755 +--- a/ruby/private/bundle/create_bundle_build_file.rb ++++ b/ruby/private/bundle/create_bundle_build_file.rb +@@ -68,9 +68,10 @@ ALL_GEMS + # + # Library path differs across implementations as `lib/ruby` on MRI and `lib/jruby` on JRuby. + GEM_PATH = ->(ruby_version, gem_name, gem_version) do +- glob = Dir.glob("lib/#{RbConfig::CONFIG['RUBY_INSTALL_NAME']}/#{ruby_version}/gems/#{gem_name}-#{gem_version}*").first +- alt_glob = Dir.glob("lib/#{RbConfig::CONFIG['RUBY_INSTALL_NAME']}/#{ruby_version}/bundler/gems/#{gem_name}-*").first +- glob || alt_glob ++ glob = Dir.glob("lib/#{RbConfig::CONFIG['RUBY_BASE_NAME']}/#{ruby_version}/gems/#{gem_name}-#{gem_version}*").first ++ alt_glob = Dir.glob("lib/#{RbConfig::CONFIG['RUBY_BASE_NAME']}/#{ruby_version}/bundler/gems/#{gem_name}-*").first ++ # alt_alt_glob = Dir.glob("lib/#{RbConfig::CONFIG['RUBY_BASE_NAME']}/gems/#{ruby_version}/gems/#{gem_name}-#{gem_version}*").first ++ glob || alt_glob # || alt_alt_glob + end + + # For ordinary gems, this path is like 'lib/ruby/3.0.0/specifications/rspec-3.10.0.gemspec'. +@@ -83,9 +84,10 @@ end + # + # Library path differs across implementations as `lib/ruby` on MRI and `lib/jruby` on JRuby. + SPEC_PATH = ->(ruby_version, gem_name, gem_version) do +- glob = Dir.glob("lib/#{RbConfig::CONFIG['RUBY_INSTALL_NAME']}/#{ruby_version}/specifications/#{gem_name}-#{gem_version}*.gemspec").first +- alt_glob = Dir.glob("lib/#{RbConfig::CONFIG['RUBY_INSTALL_NAME']}/#{ruby_version}/bundler/gems/#{gem_name}-*/**/*.gemspec").first +- glob || alt_glob ++ glob = Dir.glob("lib/#{RbConfig::CONFIG['RUBY_BASE_NAME']}/#{ruby_version}/specifications/#{gem_name}-#{gem_version}*.gemspec").first ++ alt_glob = Dir.glob("lib/#{RbConfig::CONFIG['RUBY_BASE_NAME']}/#{ruby_version}/bundler/gems/#{gem_name}-*/**/*.gemspec").first ++ # alt_alt_glob = Dir.glob("lib/#{RbConfig::CONFIG['RUBY_BASE_NAME']}/gems/#{ruby_version}/specifications/#{gem_name}-#{gem_version}*.gemspec").first ++ glob || alt_glob # || alt_alt_glob + end + + HERE = File.absolute_path '.' +@@ -199,13 +201,13 @@ class BundleBuildFileGenerator + # ruby/2.6.0/gems for all minor versions of 2.6.* + @ruby_version ||= begin + version_string = (RUBY_VERSION.split('.')[0..1] << 0).join('.') +- if File.exist?("lib/#{RbConfig::CONFIG['RUBY_INSTALL_NAME']}/#{version_string}") ++ if File.exist?("lib/#{RbConfig::CONFIG['RUBY_BASE_NAME']}/#{version_string}") + version_string + else +- if File.exist?("lib/#{RbConfig::CONFIG['RUBY_INSTALL_NAME']}/#{version_string}+0") ++ if File.exist?("lib/#{RbConfig::CONFIG['RUBY_BASE_NAME']}/#{version_string}+0") + version_string + "+0" + else +- raise "Cannot find directory named #{version_string} within lib/#{RbConfig::CONFIG['RUBY_INSTALL_NAME']}" ++ raise "Cannot find directory named #{version_string} within lib/#{RbConfig::CONFIG['RUBY_BASE_NAME']}" + end + end + end