This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #6273 - joelvh:feature/bundle_update_gemfile_option, r=…
…colby-swandale Added `--gemfile` option to `bundle update` Thanks so much for the contribution! To make reviewing this PR a bit easier, please fill out answers to the following questions. ### What was the end-user problem that led to this PR? The problem was that `BUNDLE_GEMFILE` is not respected when `.bundle/config` specifies an alternate Gemfile. However, my specific issue is that `bundle install --gemfile Gemfile2` is an option, but `bundle update` won't let me specify an alternate Gemfile. ### What was your diagnosis of the problem? My diagnosis was that Bundler copies `BUNDLE_GEMFILE` environment variable to `BUNDLE_ORIG_GEMFILE` and always uses `.bundle/config`. Simplest solution was to add parity to `bundle update` rather than diagnose why environment variables don't override `.bundle/config` settings across the board. ### What is your fix for the problem, implemented in this PR? My fix is to add the `--gemfile` option to `bundle update` for parity with `bundle install`. ### Why did you choose this fix out of the possible options? I chose this fix because this allows installing and updating alternative Gemfiles without untangling environment variables. It's the most direct use case that I'm having this issue with. Ideally, the environment variables specified for a command should be respected and override settings in `.bundle/config` (#6270). (cherry picked from commit a0592e5)
- Loading branch information
1 parent
4da61c3
commit ebdcabf
Showing
4 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe "bundle update" do | ||
context "with --gemfile" do | ||
it "finds the gemfile" do | ||
gemfile bundled_app("NotGemfile"), <<-G | ||
source "file://#{gem_repo1}" | ||
gem 'rack' | ||
G | ||
|
||
bundle! :install, :gemfile => bundled_app("NotGemfile") | ||
bundle! :update, :gemfile => bundled_app("NotGemfile"), :all => bundle_update_requires_all? | ||
|
||
# Specify BUNDLE_GEMFILE for `the_bundle` | ||
# to retrieve the proper Gemfile | ||
ENV["BUNDLE_GEMFILE"] = "NotGemfile" | ||
expect(the_bundle).to include_gems "rack 1.0.0" | ||
end | ||
end | ||
|
||
context "with gemfile set via config" do | ||
before do | ||
gemfile bundled_app("NotGemfile"), <<-G | ||
source "file://#{gem_repo1}" | ||
gem 'rack' | ||
G | ||
|
||
bundle "config --local gemfile #{bundled_app("NotGemfile")}" | ||
bundle! :install | ||
end | ||
|
||
it "uses the gemfile to update" do | ||
bundle! "update", :all => bundle_update_requires_all? | ||
bundle "list" | ||
|
||
expect(out).to include("rack (1.0.0)") | ||
end | ||
|
||
it "uses the gemfile while in a subdirectory" do | ||
bundled_app("subdir").mkpath | ||
Dir.chdir(bundled_app("subdir")) do | ||
bundle! "update", :all => bundle_update_requires_all? | ||
bundle "list" | ||
|
||
expect(out).to include("rack (1.0.0)") | ||
end | ||
end | ||
end | ||
|
||
context "with prefer_gems_rb set" do | ||
before { bundle! "config prefer_gems_rb true" } | ||
|
||
it "prefers gems.rb to Gemfile" do | ||
create_file("gems.rb", "gem 'bundler'") | ||
create_file("Gemfile", "raise 'wrong Gemfile!'") | ||
|
||
bundle! :install | ||
bundle! :update, :all => bundle_update_requires_all? | ||
|
||
expect(bundled_app("gems.rb")).to be_file | ||
expect(bundled_app("Gemfile.lock")).not_to be_file | ||
|
||
expect(the_bundle).to include_gem "bundler #{Bundler::VERSION}" | ||
end | ||
end | ||
end |