Issue #13300 has been updated by jeremyevans0 (Jeremy Evans).

Status changed from Open to Rejected

shyouhei (Shyouhei Urabe) wrote:
> We discussesed 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.

Correct.  Actually when using chroot in real applications, autoload is the most likely thing to cause breakage.  Hopefully autoload can be removed in Ruby 3.

> 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.

OK, that seems reasonable.  I've already been using a working manual solution for many months, so I will continue to use that.  Thanks for taking the time to consider this proposal, I will close this now.

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

* Author: jeremyevans0 (Jeremy Evans)
* Status: Rejected
* 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>