Fixing Gem.clear_paths to work in an environment with a Security Constan...

I recently upgraded to Rubygems 2.0.3 (and quickly 2.0.7) and started receiving this error when trying to run tests:

/Users/username/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems.rb:311:in `clear_paths': uninitialized constant Gem::Security (NameError)
	from /Users/username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/rubygems_integration.rb:312:in `replace_entrypoints'
	from /Users/username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/runtime.rb:16:in `setup'
	from /Users/username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler.rb:120:in `setup'
	from /Users/username/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/setup.rb:7:in `<top (required)>'
	from /Users/username/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:in `require'
	from /Users/username/.rbenv/versions/2.0.0-p247/lib/ruby/site_ruby/2.0.0/rubygems/core_ext/kernel_require.rb:51:in `require'

After about an hour of debugging, I found that when you have bundler configured to use local copies of some gems, it will load those gems before calling Gem.clear_paths. One of our gems defines a Security constant at the top level. This confused rubygems into thinking Gem::Security was defined (which it wasn't).

Trivially you can reproduce this error with the following script:

#!/usr/bin/env ruby
Security = 4 #Chosen by a fair die roll
Gem.clear_paths