From 3d82929cf9330b1e25e29d312c8c26ac48ad2db2 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Wed, 10 Feb 2010 21:27:53 -0800 Subject: [PATCH] Separate bundle install foo and bundle install --disable-shared-gems. --- lib/bundler.rb | 4 ++-- lib/bundler/cli.rb | 10 ++++++---- spec/install/gems_spec.rb | 40 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/lib/bundler.rb b/lib/bundler.rb index 7b4b08385c2..302286bf42b 100644 --- a/lib/bundler.rb +++ b/lib/bundler.rb @@ -114,8 +114,8 @@ def default_gemfile end def configure_gem_home_and_path - if path = settings[:path] - ENV['GEM_HOME'] = File.expand_path(path, root) + if settings[:disable_shared_gems] + ENV['GEM_HOME'] = File.expand_path(bundle_path, root) ENV['GEM_PATH'] = '' else gem_home, gem_path = Gem.dir, Gem.path diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 41e284fc637..5850e62a6f8 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -44,16 +44,18 @@ def check end desc "install", "Install the current environment to the system" - method_option :without, :type => :array, :banner => "Exclude gems that are part of the specified named group" - method_option :relock, :type => :boolean, :banner => "Unlock, install the gems, and relock" + method_option "without", :type => :array, :banner => "Exclude gems that are part of the specified named group." + method_option "relock", :type => :boolean, :banner => "Unlock, install the gems, and relock." + method_option "disable-shared-gems", :type => :boolean, :banner => "Do not use any shared gems, such as the system gem repository." def install(path = nil) - remove_lockfiles if options[:relock] - opts = options.dup opts[:without] ||= [] opts[:without].map! { |g| g.to_sym } Bundler.settings[:path] = path if path + Bundler.settings[:disable_shared_gems] = '1' if options["disable-shared-gems"] + + remove_lockfiles if options[:relock] Installer.install(Bundler.root, Bundler.definition, opts) diff --git a/spec/install/gems_spec.rb b/spec/install/gems_spec.rb index 99d3ade498a..c3e1ece26f8 100644 --- a/spec/install/gems_spec.rb +++ b/spec/install/gems_spec.rb @@ -231,6 +231,46 @@ bundled_app('vendor/gems/rack-1.0.0').should be_directory should_be_installed "rack 1.0.0" end + + it "does not disable system gems when specifying a path to install to" do + build_gem "rack", "1.1.0", :to_system => true + bundle "install ./vendor" + + bundled_app('vendor/gems/rack-1.1.0').should_not be_directory + should_be_installed "rack 1.1.0" + end + end + + describe "disabling system gems" do + before :each do + build_gem "rack", "1.0.0", :to_system => true do |s| + s.write "lib/rack.rb", "puts 'FAIL'" + end + end + + it "does not use available system gems" do + gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + G + + bundle "install --disable-shared-gems" + should_be_installed "rack 1.0.0" + end + + it "remembers to disable system gems after the first time" do + gemfile <<-G + source "file://#{gem_repo1}" + gem "rack" + G + + bundle "install vendor/gems --disable-shared-gems" + FileUtils.rm_rf bundled_app('vendor/gems') + bundle "install" + + bundled_app('vendor/gems/gems/rack-1.0.0').should be_directory + should_be_installed "rack 1.0.0" + end end describe "when packed and locked" do