diff options
author | The Bundler Bot <bot@bundler.io> | 2018-09-10 04:06:01 +0000 |
---|---|---|
committer | Colby Swandale <me@colby.fyi> | 2018-09-14 22:26:18 +1000 |
commit | 9350f465389802b5658644195c7dfa5ae39cb336 (patch) | |
tree | 9dba3331faa93515e74e3242b91d286668d5fe43 | |
parent | 696724e759da8ed7d0b1884a2d9dac84e073e0d2 (diff) | |
download | bundler-9350f465389802b5658644195c7dfa5ae39cb336.tar.gz |
Auto merge of #6692 - eregon:simplify-autoload-require-deprecate, r=segiddins
Check that Bundler::Deprecate is not an autoload constant
* Otherwise, it should be defined by this file.
* The issue is bundler/deprecate.rb checks `defined? Bundler::Deprecate`
and this would normally return true since an autoload is defined for
that constant. But since the autoload file is #require-d explicitly
(by bundler/psyched_yaml and bundler/shared_helpers), MRI makes it
undefined to save this pattern. This however requires a complex
autoload implementation and is confusing to debug, so let's simplify.
* Related to https://github.com/bundler/bundler/issues/6163 and https://github.com/rubinius/rubinius/issues/3769.
### What was the end-user problem that led to this PR?
Bundler fails in TruffleRuby without this change.
We plan to fix this case in TruffleRuby, but since at least 2 Ruby implementations did not expect such a corner case, we should make the code simpler since it's easy enough in this case.
### What was your diagnosis of the problem?
See above.
### Why did you choose this fix out of the possible options?
It's simple and does not break if an extra `require "bundler/deprecate"` is later added in the codebase.
(cherry picked from commit 02af3c2def7ea1e16ad7df4842d35f4bb568ad29)
-rw-r--r-- | lib/bundler/deprecate.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/bundler/deprecate.rb b/lib/bundler/deprecate.rb index 387f632a39..f59533630e 100644 --- a/lib/bundler/deprecate.rb +++ b/lib/bundler/deprecate.rb @@ -8,7 +8,8 @@ rescue LoadError end module Bundler - if defined? Bundler::Deprecate + # If Bundler::Deprecate is an autoload constant, we need to define it + if defined?(Bundler::Deprecate) && !autoload?(:Deprecate) # nothing to do! elsif defined? ::Deprecate Deprecate = ::Deprecate |