Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Separate bundle install foo and bundle install --disable-shared-gems.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carl Lerche committed Feb 11, 2010
1 parent 7a9d6a2 commit 3d82929
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 6 deletions.
4 changes: 2 additions & 2 deletions lib/bundler.rb
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions lib/bundler/cli.rb
Expand Up @@ -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)

Expand Down
40 changes: 40 additions & 0 deletions spec/install/gems_spec.rb
Expand Up @@ -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
Expand Down

0 comments on commit 3d82929

Please sign in to comment.