Closed cheald closed 4 years ago
It seems likely that it's related to this change: https://github.com/bundler/bundler/pull/7418/files
Under Bundler 2.0.1, ENV["BUNDLE_GEMFILE"]
after requiring bundler/inline is "Gemfile". Under 2.1.3 is it nil
. Manually setting ENV["BUNDLE_GEMFILE"] = "Gemfile"
causes it to work again.
It is worth noting that in my case, there is no file named Gemfile
in the directory we're executing in, or any parent directory.
~/projects/isolate ll
.rw-rw-r-- chris chris 169 B Thu Jan 2 09:28:49 2020 cap.rb
~/projects/isolate ruby cap.rb
~/projects/isolate echo $?
0
~/projects/isolate cat cap.rb
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "capistrano", require: false
end
ENV["BUNDLE_GEMFILE"] = "Gemfile"
require "capistrano/all"
https://github.com/bundler/bundler/blob/master/lib/bundler/shared_helpers.rb#L229-L233
It appears that when ENV["BUNDLE_GEMFILE"] is nil, bundler attempts to actually find files on disk matching the default filenames. When it is given, Bundler doesn't perform any existence check. Because bundler 2.1.0+ "restores" a nil BUNDLE_GEMFILE, we end up doing a file check for gems.rb and Gemfile, which don't exist because...we're using an inline gemfile.
My intuition here is that we want to restore BUNDLE_GEMFILE only in the case that it previously had a value. Otherwise, we want to leave it set to something so that we don't attempt to go find files that probably aren't there.
That makes sense @cheald. Let me try fix this.
Can you try out #7537?
That seems to have done the trick.
bundle -v Bundler version 2.1.3
Results in "Could not locate Gemfile":
This works fine under Bundler 2.0.1 and earlier.