diff options
author | Bundlerbot <bot@bundler.io> | 2019-04-24 08:38:47 +0000 |
---|---|---|
committer | Bundlerbot <bot@bundler.io> | 2019-04-24 08:38:47 +0000 |
commit | 5c26795f26b72e1a2faddd12448b19602aae8399 (patch) | |
tree | d06acbd7a5d2460b832725bb21b47b1aceca249d | |
parent | 58357f5bab5e7869d0532041bb44325d1832b036 (diff) | |
parent | f8ac66f5af6a349a4354f77a96e8078aabdc6d6c (diff) | |
download | bundler-5c26795f26b72e1a2faddd12448b19602aae8399.tar.gz |
Merge #7125
7125: Ignore `frozen` setting in inline mode r=indirect a=deivid-rodriguez
Fixes #7114.
### What was the end-user problem that led to this PR?
The problem was that the inline mode wouldn't work if `BUNDLE_FROZEN` is set.
### What was your diagnosis of the problem?
My diagnosis was that since we're in frozen mode, the current platform doesn't get added to the definition, and thus platform validation fails.
### What is your fix for the problem, implemented in this PR?
My fix is to temporary ignore `BUNDLE_FROZEN` for the inline mode. The inline mode can't really be frozen since it has no lock file.
Co-authored-by: David RodrÃguez <deivid.rodriguez@riseup.net>
-rw-r--r-- | lib/bundler/inline.rb | 32 | ||||
-rw-r--r-- | spec/runtime/inline_spec.rb | 14 |
2 files changed, 31 insertions, 15 deletions
diff --git a/lib/bundler/inline.rb b/lib/bundler/inline.rb index 034838b4b4..fed31ba4e3 100644 --- a/lib/bundler/inline.rb +++ b/lib/bundler/inline.rb @@ -49,26 +49,28 @@ def gemfile(install = false, options = {}, &gemfile) builder = Bundler::Dsl.new builder.instance_eval(&gemfile) - definition = builder.to_definition(nil, true) - def definition.lock(*); end - definition.validate_runtime! + Bundler.settings.temporary(:frozen => false) do + definition = builder.to_definition(nil, true) + def definition.lock(*); end + definition.validate_runtime! - missing_specs = proc do - definition.missing_specs? - end + missing_specs = proc do + definition.missing_specs? + end - Bundler.ui = ui if install - if install || missing_specs.call - Bundler.settings.temporary(:inline => true) do - installer = Bundler::Installer.install(Bundler.root, definition, :system => true) - installer.post_install_messages.each do |name, message| - Bundler.ui.info "Post-install message from #{name}:\n#{message}" + Bundler.ui = ui if install + if install || missing_specs.call + Bundler.settings.temporary(:inline => true) do + installer = Bundler::Installer.install(Bundler.root, definition, :system => true) + installer.post_install_messages.each do |name, message| + Bundler.ui.info "Post-install message from #{name}:\n#{message}" + end end end - end - runtime = Bundler::Runtime.new(nil, definition) - runtime.setup.require + runtime = Bundler::Runtime.new(nil, definition) + runtime.setup.require + end ensure bundler_module = class << Bundler; self; end bundler_module.send(:define_method, :root, old_root) if old_root diff --git a/spec/runtime/inline_spec.rb b/spec/runtime/inline_spec.rb index 5738c042bf..d837425414 100644 --- a/spec/runtime/inline_spec.rb +++ b/spec/runtime/inline_spec.rb @@ -244,6 +244,20 @@ RSpec.describe "bundler/inline#gemfile" do expect(exitstatus).to be_zero if exitstatus end + it "installs inline gems when frozen is set" do + script <<-RUBY, :env => { "BUNDLE_FROZEN" => "true" } + gemfile do + source "file://#{gem_repo1}" + gem "rack" + end + + puts RACK + RUBY + + expect(last_command.stderr).to be_empty + expect(exitstatus).to be_zero if exitstatus + end + it "installs inline gems when BUNDLE_GEMFILE is set to an empty string" do ENV["BUNDLE_GEMFILE"] = "" |