Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootsnap changes require's memoizing behavior vs vanilla Ruby #264

Open
nelhage-stripe opened this issue Jun 17, 2019 · 3 comments
Open

Comments

@nelhage-stripe
Copy link

In vanilla MRI, if you require a file via absolute path, which is also present on $LOAD_PATH, MRI internally caches it under its relative path, and will allow it to satisfy future require "relative/path" calls, even if such a call would otherwise resolve to a file earlier in $LOAD_PATH.

bootsnap does not properly implement this behavior, resulting in a difference in behavior versus MRI's require, which turned out to break our application. This is honestly an odd behavior for us to be relying on and I'm going to attempt to work around it locally, but I wanted to report the bug for visibility.

This behavior is rather unclear to me from the Ruby documentation, and arguably this could be reported as an MRI bug instead.

I've built a simple reproducer that demonstrates different behavior under bootsnap and without here: https://github.com/nelhage-stripe/bootsnap-reproducer

@burke
Copy link
Member

burke commented Jun 17, 2019

Thanks for the report, this is news to me! I'm open to anyone taking a run at fixing this but I'm unlikely to find time to work on it myself.

@aldodelgado
Copy link

I am also experiencing this issue. Does any have any suggestions on a work around until there is a proper fix?

@nelhage
Copy link

nelhage commented Jun 27, 2019

I was able to workaround by switching a $LOAD_PATH << new_dir to $LOAD_PATH.unshift(new_dir) in the location that added the problematic directory, but this isn't necessarily applicable to all cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants