How to Resolve _rb_ary_new_from_values Psych Bundle Error in Ruby Applications

Hi there I’m excited to walk you through a little Ruby adventure I recently had, complete with code, explanations and a sprinkle of hands-on practice. I’ll take you step by step through the problem I ran into, how I reproduced it, what it really means, and finally how I fixed it.

Code Error

When I tried to start my Ruby app, my terminal spat out this scary message:

: lazy symbol binding failed: Symbol not found: _rb_ary_new_from_values
Referenced from: /Users/rich/.rvm/gems/ruby-2.2.3/gems/psych-2.0.17/lib/psych.bundle
Expected in: flat namespace

dyld: Symbol not found: _rb_ary_new_from_values
Referenced from: /Users/rich/.rvm/gems/ruby-2.2.3/gems/psych-2.0.17/lib/psych.bundle
Expected in: flat namespace

Trace/BPT trap: 5

At first glance, it looked like my machine was missing something vital. But really, it was a version mismatch hiding under a confusing error.

Minimal Reproduction

To make sure I wasn’t chasing ghosts, I created a tiny Ruby script:

# demo.rb
require 'psych'

yaml_str = <<~YAML
fruits:
- apple
- banana
- cherry
YAML

data = Psych.load(yaml_str)
puts data.inspect

Then I ran:

ruby demo.rb

and sure enough, the same _rb_ary_new_from_values error showed up. That told me the problem wasn’t in my app it was in how psych was talking to Ruby.

What the Error Means

  • dyld: lazy symbol binding failed
    macOS’s dynamic linker (known as dyld) tried to load a C-level function from the psych native extension but couldn’t find it.
  • _rb_ary_new_from_values
    This function is part of Ruby’s C-API and was introduced in newer Ruby versions. My psych gem was compiled expecting that function, but at runtime I was using Ruby 2.2.3 which doesn’t provide it.
  • Root Cause
    A simple version mismatch: the psych gem version I had installed assumed a modern Ruby, but my environment was running an older one.

How I Fixed It

I tried two approaches:

  • Upgrade Ruby
    I installed a newer Ruby via RVM:
install 2.7.6
rvm use 2.7.6 --default
gem uninstall psych
gem install psych

Now psych would build against a Ruby that actually includes _rb_ary_new_from_values.

  • Pin psych to a Compatible Version
    If you can’t upgrade Ruby, you can choose a psych version that still works on 2.2.3. In my project’s Gemfile I added:
gem 'psych', '~> 2.0', '< 2.0.17'

Then ran

bundle update psych

Either way, rebuilding the native extension made the error disappear.

Enhanced Demo with Error Handling & Practice

I didn’t stop at just fixing it I also beefed up my demo script to:

  • Detect if psych fails to load
  • Fall back to Ruby’s pure-Ruby YAML parser
  • Offer an interactive CLI so I (or you!) can paste any YAML and see how it parses
#!/usr/bin/env ruby
# enhanced_demo.rb

begin
require 'psych'
PARSER = :psych
rescue StandardError => e
warn "[Warning] psych load failed: #{e.class} – #{e.message}"
require 'yaml'
PARSER = :syck
end

def load_yaml(str)
PARSER == :psych ? Psych.load(str) : YAML.safe_load(str)
end

def practice_session
puts "Paste YAML (end with blank line):"
lines = []
loop do
line = gets.chomp
break if line.empty?
lines << line
end

input = lines.join("\n")
begin
result = load_yaml(input)
puts "✅ Parsed: #{result.inspect}"
rescue StandardError => e
puts "❌ Parse error: #{e.class}: #{e.message}"
end
end

def main
puts "Using parser: #{PARSER}"
sample = <<~YML
colors:
- red
- green
- blue
YML

puts "Sample parse => #{load_yaml(sample).inspect}"
puts "\n--- Your turn! ---"
practice_session
end

main if __FILE__ == $0

How to try it yourself:

+x enhanced_demo.rb
./enhanced_demo.rb

You’ll see which parser is in use, a sample result, and then you can paste your own YAML to see it in action.

Final Thoughts

I love how a single error message can lead you down a path of discovery from learning about Ruby’s C-API symbols to mastering fallback strategies and interactive demos. If you ever bump into _rb_ary_new_from_values or any other missing-symbol issue, remember:

  • Check for version mismatches first
  • Upgrade Ruby or pin your gems to compatible releases
  • Recompile native extensions when in doubt

And feel free to use my enhanced demo as a playground for understanding YAML parsing under the hood.

Related blog posts