From 7df03e65bfbfc6e72eac6a8c726fb936d7eee8b5 Mon Sep 17 00:00:00 2001 From: Agis Anastasopoulos Date: Sun, 25 Oct 2015 12:19:14 +0200 Subject: [PATCH] Warn if RUBYGEMS_GEMDEPS env. variable is set Closes #3656. --- lib/bundler/cli.rb | 7 +++++++ spec/bundler/cli_spec.rb | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 921cd1e68ba..138ce5d7b59 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -29,6 +29,13 @@ def initialize(*args) self.options ||= {} Bundler.ui = UI::Shell.new(options) Bundler.ui.level = "debug" if options["verbose"] + + if ENV["RUBYGEMS_GEMDEPS"] && !ENV["RUBYGEMS_GEMDEPS"].empty? + Bundler.ui.warn( + "The RUBYGEMS_GEMDEPS environment variable is set. This enables RubyGems' " \ + "experimental Gemfile mode, which may conflict with Bundler and cause unexpected errors. " \ + "To remove this warning, unset RUBYGEMS_GEMDEPS.", :wrap => true) + end end check_unknown_options!(:except => [:config, :exec]) diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb index 1d5ee7b072c..a2f87e45fac 100644 --- a/spec/bundler/cli_spec.rb +++ b/spec/bundler/cli_spec.rb @@ -37,4 +37,20 @@ should_be_installed "rack 1.0.0" end end + + context "when ENV['RUBYGEMS_GEMDEPS'] is set" do + it "displays a warning" do + gemfile bundled_app("Gemfile"), <<-G + source "file://#{gem_repo1}" + gem 'rack' + G + + bundle :install, :env => { "RUBYGEMS_GEMDEPS" => "foo" } + expect(out).to include("RUBYGEMS_GEMDEPS") + expect(out).to include("conflict with Bundler") + + bundle :install, :env => { "RUBYGEMS_GEMDEPS" => "" } + expect(out).not_to include("RUBYGEMS_GEMDEPS") + end + end end