Skip to content

Add spec for require after $LOAD_PATH change #1881

Merged
merged 3 commits into from Apr 26, 2013

4 participants

@LTe
LTe commented Aug 31, 2012

When developer add something to $LOAD_PATH and require once again the same file ruby should not require it once again.

Example:

Rubinius have lib/racc/parser.rb file. And this file will require after bootstrap.

require 'racc/parser'

After require rubygems $LOAD_PATH will change and now we have access to two version on racc/parser (from Rubinius /lib and /gems/racc). When user try to require once again rubinius will search via $LOAD_PATH and hit racc/parser from RUBYGEMS. In ruby 1.9 mode all paths are expanded so rubinius will require once again racc/parser. This is because in $LOADED_FEATURES we can find only [rubinius_path]/lib/racc/parser.rb. When CodeLoader will find file in $LOAD_PATH ([rubygems]/racc/parser.rb) and full path of this file is not part of $LOADED_FEATURES so parser.rb file will be load once again.

Any ideas how to recognize already loaded file (but from other full path)?

This spec reproduce @txus gist click
Related to issue #1571

@travisbot

This pull request fails (merged db572b0 into 149a364).

@dbussink
Rubinius member

Did you work further on implementing these changes on the Rubinius side to pass these specs?

@LTe
LTe commented Sep 27, 2012

No, but I can add fail tag and after that this pull request can be merged.

@stouset
stouset commented Mar 28, 2013

Can you add this fail tag, so we can merge the spec?

LTe added some commits Aug 31, 2012
@LTe LTe Add spec for require after $LOAD_PATH change
When developer add something to $LOAD_PATH and require once again the
same file ruby should not require it once again.

Example:

Rubinius have lib/racc/parser.rb file. And this file will require after
bootstrap.

  require 'racc/parser'

After require 'rubygems' $LOAD_PATH will change and now we have access
to two version on 'racc/parser' (from Rubinius /lib and /gems/racc).
When user try to require once again rubinius will search via $LOAD_PATH
and hit racc/parser from _RUBYGEMS_. In ruby 1.9 mode all paths are
expanded so rubinius will require once again 'racc/parser'. This is
because in $LOADED_FEATURES we can find only
"[rubinius_path]/lib/racc/parser.rb". When CodeLoader will find file in
$LOAD_PATH ([rubygems]/racc/parser.rb) and full path is not part of
$LOADED_FEATURES this file will be load once again.
ecf3cbc
@LTe LTe Add fail tags for require after $LOAD_PATH change b9f917c
@LTe
LTe commented Mar 29, 2013

@stouset updated ;)

@stouset
stouset commented Mar 29, 2013

Your push doesn't seem to have had the desired effect of making Travis pass — the tests you added are still failing. You can either figure out the issue and solve it on your end, or I can try and take a look this weekend if I get a chance.

@dbussink dbussink merged commit 4059190 into rubinius:master Apr 26, 2013

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.