Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Separate bundle install foo and bundle install --disable-shared-gems.

  • Loading branch information...
commit 3d82929cf9330b1e25e29d312c8c26ac48ad2db2 1 parent 7a9d6a2
Carl Lerche authored
Showing with 48 additions and 6 deletions.
  1. +2 −2 lib/bundler.rb
  2. +6 −4 lib/bundler/cli.rb
  3. +40 −0 spec/install/gems_spec.rb
View
4 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
View
10 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)
View
40 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
Please sign in to comment.
Something went wrong with that request. Please try again.