carlhuda/bundler — pull request #1487 by maxjustus (2011-10-18 23:16:30+00:00)
Title: Attempt to load Psych from Gemfile before loading system Psych

I added a simple attempt to load the installed gem version of Psych before doing require 'psych'.
Not doing this results in the following scenario being possible:

ruby-1.9.2-p290 :001 > require 'psych'
=> true
ruby-1.9.2-p290 :003 > Psych.dump(1)
=> "--- 1\n...\n"
ruby-1.9.2-p290 :002 > gem 'psych'
=> true
ruby-1.9.2-p290 :003 > require 'psych'
/Users/maxjustus/.rvm/gems/ruby-1.9.2-p290/gems/psych-1.2.2/lib/psych.rb:93: warning: already initialized constant VERSION
/Users/maxjustus/.rvm/gems/ruby-1.9.2-p290/gems/psych-1.2.2/lib/psych.rb:96: warning: already initialized constant LIBYAML_VERSION
=> true
ruby-1.9.2-p290 :006 > Psych.dump(1)
NoMethodError: undefined method `yaml' for #

i.e. system psych is loaded by bundler, and then in an application (such as Rails) gem psych is on top of it, resulting in a clobbered and unusable instance of psych.