Skip to content

Commit 75e2dd5

Browse files
justin808claude
andcommitted
fix: Add backward compatibility for YAML.load_file across Psych versions
The `YAML.load_file(path, aliases: true)` syntax works on Ruby 3.4+ with Psych 5+, but raises ArgumentError on older Ruby/Psych versions that don't support the aliases parameter. Added graceful fallback with rescue to support all Ruby versions: - Try loading with `aliases: true` first (Psych 5+) - Fall back to `YAML.load_file(path)` on ArgumentError (older Psych) This ensures the generator works across all supported Ruby versions without breaking CI on older Ruby environments. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 6904f59 commit 75e2dd5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/generators/react_on_rails/base_generator.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,13 @@ def configure_rspack_in_shakapacker
412412
puts Rainbow("🔧 Configuring Shakapacker for Rspack...").yellow
413413

414414
# Parse YAML config properly to avoid fragile regex manipulation
415-
config = YAML.load_file(shakapacker_config_path, aliases: true)
416-
415+
# Support both old and new Psych versions
416+
config = begin
417+
YAML.load_file(shakapacker_config_path, aliases: true)
418+
rescue ArgumentError
419+
# Older Psych versions don't support the aliases parameter
420+
YAML.load_file(shakapacker_config_path)
421+
end
417422
# Update default section
418423
config["default"] ||= {}
419424
config["default"]["assets_bundler"] = "rspack"

0 commit comments

Comments
 (0)