From 95298a24a2c2b039499e55bbada93abaeedf7ab3 Mon Sep 17 00:00:00 2001 From: "Daniel (dB.) Doubrovkine" Date: Sun, 22 Nov 2026 10:10:46 -0500 Subject: [PATCH] Document Gem.loaded_specs for release Gemfile tasks Recommend installing the release tasks only when ruby-gem-release is in the active bundle instead of rescuing LoadError, which also hides real load failures in the gem or its dependencies and silently drops the release tasks. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_011Gr21htyJfr8XZGHBcPwkW --- CHANGELOG.md | 1 + docs/actions/release.md | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 501683d..0842b23 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - [#92](https://github.com/dblock/ruby-gem-release/pull/92): Document manual recovery from the preserved bundle when the default branch advances during publication - [@dblock](https://github.com/dblock). - [#93](https://github.com/dblock/ruby-gem-release/pull/93): Document disabling the local Bundler `release` tasks so the workflow is the only release path - [@dblock](https://github.com/dblock). - [#95](https://github.com/dblock/ruby-gem-release/pull/95): Rewrite the documentation in plain language, consolidating repeated rules so each lives in one place - [@dblock](https://github.com/dblock). +- [#98](https://github.com/dblock/ruby-gem-release/pull/98): Document installing release tasks from a separate release Gemfile with `Gem.loaded_specs` instead of `rescue LoadError` - [@dblock](https://github.com/dblock). - Your contribution here. ## 0.9.0 (2026/11/20) diff --git a/docs/actions/release.md b/docs/actions/release.md index 90fe983..a6d6c1d 100644 --- a/docs/actions/release.md +++ b/docs/actions/release.md @@ -92,7 +92,21 @@ gem 'commonmarker', '~> 2.10', require: false gem 'ruby-gem-release', '0.9.0', require: false ``` -The workflow sets `BUNDLE_GEMFILE` for the whole job, so every step and default command, including the full `test` suite, uses this bundle. Commit or ignore the lockfile Bundler writes next to it; an untracked lockfile fails the clean-checkout check. In your Rakefile, wrap the release task setup in `rescue LoadError` so the main bundle works without the gem. +The workflow sets `BUNDLE_GEMFILE` for the whole job, so every step and default command, including the full `test` suite, uses this bundle. Commit or ignore the lockfile Bundler writes next to it; an untracked lockfile fails the clean-checkout check. In your Rakefile, install the release tasks only when the gem is in the active bundle, so the main bundle works without it: + +```ruby +if Gem.loaded_specs.key?('ruby-gem-release') + require 'ruby-gem-release/workflow/ruby_gem' + require 'ruby-gem-release/changelog' + + RubyGemRelease::Workflow::RubyGem.new( + version: RubyGemRelease::Version::RubyConstant.new(path: 'lib/example/version.rb', constant: 'VERSION'), + changelog: RubyGemRelease::Changelog::KeepAChangelog.new + ).install_tasks +end +``` + +Prefer this to `rescue LoadError`, which also hides a real load failure in the gem or its dependencies and silently drops the release tasks. ### Timezone