Skip to content

Fix: explicitly require react_on_rails in react_on_rails_pro.rb#2492

Merged
ihabadham merged 2 commits intomasterfrom
ihabadham/fix/require-ror-in-rorp
Feb 26, 2026
Merged

Fix: explicitly require react_on_rails in react_on_rails_pro.rb#2492
ihabadham merged 2 commits intomasterfrom
ihabadham/fix/require-ror-in-rorp

Conversation

@ihabadham
Copy link
Copy Markdown
Collaborator

@ihabadham ihabadham commented Feb 26, 2026

Summary

Fixes #2491

react_on_rails_pro.rb never explicitly required react_on_rails, relying instead on Bundler.require to auto-require it via the user's Gemfile. This worked as long as users listed both gems explicitly — react_on_rails sorts alphabetically before react_on_rails_pro, so Bundler always loaded the core gem first.

When installation docs were updated (PR #2252) to direct users to only add react_on_rails_pro to their Gemfile, Bundler.require stopped auto-requiring the core gem (Bundler only requires explicitly listed gems, not transitive dependencies). This caused two boot failures:

  1. NoMethodError: undefined method 'strip_heredoc' for an instance of Stringactive_support/core_ext/string/strip was never loaded
  2. NoMethodError: undefined method 'configure' for module ReactOnRailsreact_on_rails_pro.rb partially opens the ReactOnRails namespace via individual internal requires (react_on_rails/error, react_on_rails/utils), but configure is only defined when the full react_on_rails.rb is loaded

Fix

Add require "react_on_rails" to react_on_rails_pro.rb. This completes what the JS package split (PR #1841) established as the intended design: Pro users get everything from a single entry point. The npm package already does this correctly by declaring react-on-rails as a dependency and re-exporting it. The Ruby gem now matches that contract.

This is standard Ruby gem practice — a gem with a hard runtime dependency should load it explicitly rather than relying on the consumer's Gemfile.

Verification

Both errors reproduced locally against master, both resolved by this fix:

ERROR 1: undefined method `strip_heredoc' for an instance of String  ✅ fixed
ERROR 2: undefined method `configure' for module ReactOnRails         ✅ fixed

Test plan

  • Boot a Rails app with only react_on_rails_pro in the Gemfile — no errors
  • CI passes

Summary by CodeRabbit

  • Bug Fixes

    • Fixed a boot error that could occur when only the pro extension was present in the application.
    • Restored compatibility with newer Sentry Node SDKs (v9/v10), improving error reporting across supported versions.
  • Chores

    • Updated internal integration to ensure proper cooperation with the main ReactOnRails gem.

Mirrors the JS package split design: react-on-rails-pro declares
react-on-rails as a dependency and users only need one entry point.
The Ruby gem was never updated to match — it relied on Bundler.require
loading react_on_rails first via explicit Gemfile listing.

With docs now directing users to only list react_on_rails_pro in their
Gemfile, react_on_rails is never auto-required, causing two failures:
- NoMethodError: undefined method strip_heredoc (license_public_key.rb)
- NoMethodError: undefined method configure for module ReactOnRails

Adding require "react_on_rails" ensures the full core gem loads
regardless of Gemfile order or whether the user lists it explicitly.

Fixes #2491

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 26, 2026

Walkthrough

Added an explicit require "react_on_rails" to react_on_rails_pro/lib/react_on_rails_pro.rb to ensure the main ReactOnRails gem loads before the pro extension; updated CHANGELOG entries documenting the boot fix and Sentry compatibility change.

Changes

Cohort / File(s) Summary
Load order fix
react_on_rails_pro/lib/react_on_rails_pro.rb
Inserted require "react_on_rails" after the Rails require to load the main gem before the pro extension, preventing boot failures when only react_on_rails_pro is listed in the Gemfile.
Changelog updates
CHANGELOG.md
Added fixed entries noting the boot fix (explicit require) and Sentry SDK v9/v10 compatibility / peer dependency range update.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 One little require, snug and bright,
Rails then React in proper sight.
No more boot stumbles in the night,
Pro joins Main and all is right. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title clearly and specifically summarizes the main change: explicitly requiring react_on_rails in react_on_rails_pro.rb to fix boot failures.
Linked Issues check ✅ Passed The code change directly addresses the linked issue #2491 by explicitly requiring react_on_rails to ensure ActiveSupport extensions and core ReactOnRails methods are available during boot.
Out of Scope Changes check ✅ Passed All changes in the pull request (adding require statement and CHANGELOG entries) are directly related to fixing the boot failure issue described in #2491.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ihabadham/fix/require-ror-in-rorp

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Feb 26, 2026

Code Review

Overall: The fix is correct, minimal, and well-motivated. The root cause analysis in the PR description is thorough and accurate.

What the PR does

Adds require "react_on_rails" to react_on_rails_pro.rb so the gem is self-contained regardless of what the user lists in their Gemfile.

Positive aspects

  • Minimal and focused — one line, exactly what's needed.
  • Idiomatic — standard Ruby practice for gems with hard runtime dependencies.
  • Safe — Ruby's require is idempotent (Kernel tracks loaded features in $LOADED_FEATURES), so this will not cause a double-load for users who have both gems in their Gemfile.
  • Consistent with the JS side — mirrors what the npm package already does by declaring react-on-rails as a dependency and re-exporting it.
  • Gemspec alignment — the gemspec already correctly declares react_on_rails as a runtime dependency (s.add_runtime_dependency "react_on_rails", ReactOnRails::VERSION); this change makes the Ruby require graph match that declared dependency.

One issue: CHANGELOG entry missing

This fix resolves user-facing boot failures (NoMethodError: undefined method 'strip_heredoc' and NoMethodError: undefined method 'configure'), which warrants a CHANGELOG entry. The repo's CHANGELOG.md has an [Unreleased] section with a #### Pro / ##### Fixed subsection — this fix belongs there.

Example entry:

- **Explicit require of react_on_rails in react_on_rails_pro**: Fixed boot failures (`NoMethodError: undefined method 'strip_heredoc'` and `NoMethodError: undefined method 'configure' for module ReactOnRails`) when only `react_on_rails_pro` is listed in the Gemfile. The gem now explicitly requires its `react_on_rails` runtime dependency rather than relying on Bundler auto-require ordering. [PR 2492](https://github.com/shakacode/react_on_rails/pull/2492) by [ihabadham](https://github.com/ihabadham).

Summary

The fix itself is ship-ready. The only request is to add a CHANGELOG entry before merging.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Feb 26, 2026

Greptile Summary

Adds explicit require "react_on_rails" to react_on_rails_pro.rb to ensure the core gem loads correctly when users only add react_on_rails_pro to their Gemfile (as recommended by updated installation docs).

What changed:

  • Single line added: require "react_on_rails" after require "rails"

Why this fix is correct:

  • react_on_rails_pro.gemspec declares react_on_rails as a runtime dependency
  • Previously relied on Bundler.require auto-requiring, which only works for explicitly listed gems, not transitive dependencies
  • This matches standard Ruby gem practice: explicitly require runtime dependencies
  • The npm package already follows this pattern correctly
  • Test suite already uses this pattern in spec_helper.rb

Resolved issues:

  • Fixed NoMethodError: undefined method 'strip_heredoc' (ActiveSupport extension not loaded)
  • Fixed NoMethodError: undefined method 'configure' for module ReactOnRails (core module not fully loaded)

Confidence Score: 5/5

  • This PR is safe to merge with no risk
  • The fix is a single-line addition following standard Ruby gem practice. It explicitly requires a documented runtime dependency, resolves two confirmed boot failures, and matches the pattern already used in the test suite. No breaking changes or side effects.
  • No files require special attention

Important Files Changed

Filename Overview
react_on_rails_pro/lib/react_on_rails_pro.rb Added explicit require "react_on_rails" to ensure core gem loads correctly regardless of Gemfile configuration

Last reviewed commit: 3b1fca9

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@claude
Copy link
Copy Markdown
Contributor

claude Bot commented Feb 26, 2026

Review

The fix is correct and well-reasoned. A few notes:

What is right:

  • require in Ruby is idempotent, so users who still list both gems explicitly in their Gemfile will not be affected.
  • No circular dependency risk — react_on_rails never requires react_on_rails_pro.
  • The explicit require matches what the gemspec already declares as a hard runtime dependency (s.add_runtime_dependency "react_on_rails"), so this brings the code into alignment with the declared contract.
  • Minimal, targeted change.

One suggestion — inline code comment:
A brief comment on the new line would help future maintainers understand why the explicit require is necessary rather than relying on the gemspec. Without it, someone might reasonably wonder why it is needed and remove it. See inline comment.

Test coverage gap:
The test plan is manual. react_on_rails_pro/spec/react_on_rails_pro/react_on_rails_pro_spec.rb already exists and would be a natural home for a regression test to verify that ReactOnRails responds to configure after requiring react_on_rails_pro. This would catch any future regression where someone removes the explicit require.

CHANGELOG: Correctly placed under Pro > Fixed, well-written entry.

Comment thread react_on_rails_pro/lib/react_on_rails_pro.rb
@ihabadham ihabadham merged commit 97b3d72 into master Feb 26, 2026
22 of 23 checks passed
@ihabadham ihabadham deleted the ihabadham/fix/require-ror-in-rorp branch February 26, 2026 19:48
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.

react_on_rails_pro/license_public_key.rb:18:in '<module:LicensePublicKey>': undefined method 'strip_heredoc' for an instance of String (NoMethodError)

3 participants