Skip to content

Conversation

@takaokouji
Copy link
Collaborator

Summary

Fix CI failure on Ruby 2.6/2.7 with Rails 6.0 due to NoMethodError: undefined method 'unsafe_load' for Psych:Module.

Problem

The Psych.unsafe_load method was added in Psych 4.0 (Ruby 3.1). The previous condition checked for Psych::VERSION >= 3.1, which incorrectly triggered on Ruby 2.6/2.7 where unsafe_load doesn't exist.

Solution

Changed the condition to use Psych.respond_to?(:unsafe_load) to properly detect when the method is available.

Affected environments

  • Ruby 2.6 Rails 6.0.6 (PostgreSQL/SQLite)
  • Ruby 2.7 Rails 6.0.6 (PostgreSQL/SQLite)

🤖 Generated with Claude Code

The `Psych.unsafe_load` method was added in Psych 4.0 (Ruby 3.1).
The previous condition checked for Psych::VERSION >= 3.1, which
incorrectly triggered on Ruby 2.6/2.7 where `unsafe_load` doesn't exist.

Changed the condition to use `Psych.respond_to?(:unsafe_load)` to
properly detect when the method is available.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@takaokouji takaokouji merged commit 779b035 into master Jan 20, 2026
60 checks passed
@takaokouji takaokouji deleted the fix/psych-ruby-2.6-2.7-compatibility branch January 20, 2026 13:52
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.

1 participant