Issue #13300 has been updated by shyouhei (Shyouhei Urabe).


We discusses this issue at the developer meeting yesterday.

It seems practically not possible to provide a solution that works for everyone; for instance autoloads might break because the then-specified autoload library might become out of sight. You might have placed everything inside of your chroot tree but that's not what the process can make sure.

Also, we could not be confident that LOADED_FEATURES and LOAD_PATH are the only thing that has to be tweaked before/after chroot.

Luckily you can modify LOADED_FEATURES from ruby scripts.  I advice you to do what you want manually for now.

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

* Author: jeremyevans0 (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>