[ruby-core:78336] [Ruby trunk Bug#9244][Rejected] unexpected behaviour of 'require' when $LOAD_PATH gets changed

From: matz@...
Date: 2016-11-25 08:55:41 UTC
List: ruby-core #78336
Issue #9244 has been updated by Yukihiro Matsumoto.

Status changed from Feedback to Rejected

I'd like to keep compatibility rather than reducing confusion slightly.
In any way, modifying $LOAD_PATH on the fly is not encouraged in modern Ruby.

Matz.


----------------------------------------
Bug #9244: unexpected behaviour of 'require' when $LOAD_PATH gets changed
https://bugs.ruby-lang.org/issues/9244#change-61700

* Author: Sylvain Joyeux
* Status: Rejected
* Priority: Normal
* Assignee: 
* ruby -v: 1.9.3p484, 2.0.0p353, 2.1.2 2.1.6p336 2.2.1p85 2.3.1p112
* Backport: 
----------------------------------------
For the purpose of reproducing the error, let's assume that I have two folders ```a``` and ```b``` which both contain a file ```test.rb```

In the following script, ```b/test.rb``` will NOT get loaded:

```
 $LOAD_PATH.unshift File.join(Dir.pwd, 'a')
 require 'test.rb'
 $LOAD_PATH.unshift File.join(Dir.pwd, 'b')
 require 'test.rb'
```

I would have expected this behaviour before, when required files were not registered through their absolute paths in $LOADED_FEATURES. Right now, I find it confusing.






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

In This Thread

Prev Next