{"id":28519749,"url":"https://github.com/bazel-contrib/rules_ruby","last_synced_at":"2025-07-05T13:31:55.481Z","repository":{"id":141688545,"uuid":"537554611","full_name":"bazel-contrib/rules_ruby","owner":"bazel-contrib","description":"Ruby ruleset for Bazel","archived":false,"fork":false,"pushed_at":"2025-06-27T05:11:15.000Z","size":23214,"stargazers_count":39,"open_issues_count":22,"forks_count":15,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-06-28T05:09:27.363Z","etag":null,"topics":["bazel","bazel-rules"],"latest_commit_sha":null,"homepage":"","language":"Starlark","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bazel-contrib.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"open_collective":"bazel-rules-authors-sig"}},"created_at":"2022-09-16T17:20:57.000Z","updated_at":"2025-06-24T14:32:18.000Z","dependencies_parsed_at":"2024-04-03T23:27:25.180Z","dependency_job_id":"44645a45-ece2-438b-bc83-91921f593066","html_url":"https://github.com/bazel-contrib/rules_ruby","commit_stats":null,"previous_names":["bazel-contrib/rules_ruby"],"tags_count":32,"template":false,"template_full_name":null,"purl":"pkg:github/bazel-contrib/rules_ruby","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazel-contrib%2Frules_ruby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazel-contrib%2Frules_ruby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazel-contrib%2Frules_ruby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazel-contrib%2Frules_ruby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bazel-contrib","download_url":"https://codeload.github.com/bazel-contrib/rules_ruby/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bazel-contrib%2Frules_ruby/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263749811,"owners_count":23505454,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bazel","bazel-rules"],"created_at":"2025-06-09T06:30:26.528Z","updated_at":"2025-07-05T13:31:55.473Z","avatar_url":"https://github.com/bazel-contrib.png","language":"Starlark","funding_links":["https://opencollective.com/bazel-rules-authors-sig"],"categories":[],"sub_categories":[],"readme":"# Ruby Rules for Bazel\n\n## Overview\n\nThis repository hosts [Ruby][1] language ruleset for [Bazel][2].\n\nThe ruleset is known to work with:\n\n- Bazel 8 using WORKSPACE and Bzlmod *(tested on CI)*.\n- Bazel 7 using WORKSPACE and Bzlmod *(no longer tested on CI)*.\n- Bazel 6 using WORKSPACE and Bzlmod *(no longer tested on CI)*.\n\n## Getting Started\n\n### WORKSPACE\n\n1. Install the ruleset following WORKSPACE instructions on the [latest release][13].\n2. Download and install Ruby:\n\n```bazel\n# WORKSPACE\nload(\"@rules_ruby//ruby:deps.bzl\", \"rb_register_toolchains\")\n\nrb_register_toolchains(\n    version = \"3.1.6\",\n    # alternatively, load version from .ruby-version file\n    # version_file = \"//:.ruby-version\",\n)\n```\n\n3. *(Optional)* Download and install Bundler dependencies:\n\n```bazel\n# WORKSPACE\nload(\"@rules_ruby//ruby:deps.bzl\", \"rb_bundle_fetch\")\n\nrb_bundle_fetch(\n    name = \"bundle\",\n    gemfile = \"//:Gemfile\",\n    gemfile_lock = \"//:Gemfile.lock\",\n)\n```\n\n4. Start defining your library, binary and test targets in `BUILD` files.\n\n### Bzlmod\n\n1. Install ruleset following Bzlmod instructions on the [latest release][13].\n2. Download and install Ruby:\n\n```bazel\n# MODULE.bazel\nruby = use_extension(\"@rules_ruby//ruby:extensions.bzl\", \"ruby\")\nruby.toolchain(\n    name = \"ruby\",\n    version = \"3.0.6\",\n    # alternatively, load version from .ruby-version file\n    # version_file = \"//:.ruby-version\",\n)\nuse_repo(ruby, \"ruby\")\n```\n\n3. _(Optional)_ Download and install Bundler dependencies:\n\n```bazel\n# MODULE.bazel\nruby.bundle_fetch(\n    name = \"bundle\",\n    gemfile = \"//:Gemfile\",\n    gemfile_lock = \"//:Gemfile.lock\",\n)\nuse_repo(ruby, \"bundle\", \"ruby_toolchains\")\n```\n\n4. Register Ruby toolchains:\n\n```bazel\n# MODULE.bazel\nregister_toolchains(\"@ruby_toolchains//:all\")\n```\n\n4. Start defining your library, binary and test targets in `BUILD` files.\n\n## Documentation\n\n- See [repository rules][3] for the documentation of `WORKSPACE` rules.\n- See [rules][4] for the documentation of `BUILD` rules.\n\n## Examples\n\nSee [`examples`][14] directory for a comprehensive set of examples how to use the ruleset.\n\n## Toolchains\n\nThe following toolchains are known to work and tested on CI.\n\n| Ruby             | Linux | macOS | Windows |\n|------------------|-------|-------|---------|\n| MRI 3.5          | 🟩    | 🟩    | 🟥      |\n| MRI 3.4          | 🟩    | 🟩    | 🟩      |\n| MRI 3.3          | 🟩    | 🟩    | 🟩      |\n| MRI 3.2          | 🟩    | 🟩    | 🟩      |\n| JRuby 10.0       | 🟩    | 🟩    | 🟩      |\n| TruffleRuby 24.0 | 🟩    | 🟩    | 🟥      |\n\nThe following toolchains were previously known to work but *no longer tested on CI*.\n\n| Ruby             | Linux | macOS | Windows |\n|------------------|-------|-------|---------|\n| MRI 3.1          | 🟩    | 🟩    | 🟩      |\n| MRI 3.0          | 🟩    | 🟩    | 🟩      |\n| MRI 2.7          | 🟩    | 🟩    | 🟩      |\n| JRuby 9.4        | 🟩    | 🟩    | 🟩      |\n| JRuby 9.3        | 🟩    | 🟩    | 🟩      |\n| TruffleRuby 23.0 | 🟩    | 🟩    | 🟥      |\n| TruffleRuby 22.0 | 🟩    | 🟩    | 🟥      |\n\n### MRI\n\nOn Linux and macOS, [ruby-build][5] is used to install MRI from sources.\nKeep in mind, that it takes some time for compilation to complete.\n\nOn Windows, [RubyInstaller][6] is used to install MRI.\n\n### JRuby\n\nOn all operating systems, JRuby is downloaded manually.\nIt uses Bazel runtime Java toolchain as JDK.\nJRuby is currently the only toolchain that supports [Remote Build Execution][15].\n\n### TruffleRuby\n\nOn Linux and macOS, [ruby-build][5] is used to install TruffleRuby.\nWindows is not supported.\n\n### Other\n\nOn Linux and macOS, you can potentially use any Ruby distribution that is supported by [ruby-build][5].\nHowever, some are known not to work or work only partially (e.g. mRuby has no bundler support).\n\n## Known Issues\n\n* JRuby/TruffleRuby might need `HOME` variable exposed.\n  See [`examples/gem/.bazelrc`][7] to learn how to do that.\n  This is to be fixed in [`jruby/jruby#5661`][9] and [`oracle/truffleruby#2784`][10].\n* JRuby might fail with `Errno::EACCES: Permission denied - NUL` error on Windows.\n  You need to configure JDK to allow proper access.\n  This is described in [`jruby/jruby#7182`][11].\n* RuboCop \u003c 1.55 crashes with `LoadError` on Windows.\n  This is fixed in [`rubocop/rubocop#12062`][12].\n* REPL doesn't work when used with `bazel test`.\n  To work it around, use a debugger with remote client support such as [`ruby/debug`][8] .\n  See [`examples/gem/.bazelrc`][7] to learn how to do that.\n* Some gems contain files with spaces which cause Bazel error `link or target filename contains space`.\n  To work it around, use [`--experimental_inprocess_symlink_creation`][16] Bazel flag.\n  See [`bazelbuild/bazel#4327`][17] for more details.\n\n\n[1]: https://www.ruby-lang.org\n[2]: https://bazel.build\n[3]: docs/repository_rules.md\n[4]: docs/rules.md\n[5]: https://github.com/rbenv/ruby-build\n[6]: https://rubyinstaller.org\n[7]: examples/gem/.bazelrc\n[8]: https://github.com/ruby/debug\n[9]: https://github.com/jruby/jruby/issues/5661\n[10]: https://github.com/oracle/truffleruby/issues/2784\n[11]: https://github.com/jruby/jruby/issues/7182#issuecomment-1112953015\n[12]: https://github.com/rubocop/rubocop/pull/12062\n[13]: https://github.com/bazel-contrib/rules_ruby/releases/tag/v0.3.0\n[14]: examples/\n[15]: https://bazel.build/remote/rbe\n[16]: https://bazel.build/reference/command-line-reference#flag--experimental_inprocess_symlink_creation\n[17]: https://github.com/bazelbuild/bazel/issues/4327\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbazel-contrib%2Frules_ruby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbazel-contrib%2Frules_ruby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbazel-contrib%2Frules_ruby/lists"}