Issue #13300 has been reported by Jeremy Evans.

----------------------------------------
Feature #13300: Strip chroot path from $LOADED_FEATURES when calling Dir.chroot
https://bugs.ruby-lang.org/issues/13300

* Author: Jeremy Evans
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
Currently, `Dir.chroot` doesn't modify `$LOADED_FEATURES`, leading
to a situation where `Kernel#require` will attempt to load the same
file twice, or a different file not at all because it thinks it
is already loaded.

With this example code:

~~~ ruby
require 'fileutils'
File.write('baz.rb', 'A = 1')
require './baz'
pwd = Dir.pwd
Dir.chroot(pwd)
require './baz'
FileUtils.mkdir_p(pwd)
File.write(File.join(pwd, 'baz.rb'), '$a = 2')
require "#{pwd}/baz"
warn "$a => #{$a.inspect}" unless $a == 2
~~~

Previous output on stderr:

~~~
/baz.rb:1: warning: already initialized constant A
/home/billg/baz.rb:1: warning: previous definition of A was here
$a => nil
~~~

With this patch, no output on stderr.

---Files--------------------------------
0001-Strip-chroot-path-from-LOADED_FEATURES-when-calling-.patch (2.6 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>