summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2014-03-31 17:58:26 +0800
committerAndre Arko <andre@arko.net>2014-03-31 17:58:39 +0800
commitb98022843434b7d2482ce62f4fa7a2d2422b90c7 (patch)
treef5911a47464f7cee388e64ad07e7bda4dce9dc61
parentb31fcfb9a3f2c0f7a72a68c3ba799abb22abbf1a (diff)
downloadbundler-b98022843434b7d2482ce62f4fa7a2d2422b90c7.tar.gz
install to new dir inside root-owned dir
-rw-r--r--lib/bundler/installer.rb16
-rw-r--r--spec/install/gems/sudo_spec.rb17
2 files changed, 25 insertions, 8 deletions
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index 5643b202aa..e220aed2c6 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -48,13 +48,7 @@ module Bundler
#
# Finally: TODO add documentation for how the standalone process works.
def run(options)
- # Create the BUNDLE_PATH directory
- begin
- Bundler.bundle_path.mkpath unless Bundler.bundle_path.exist?
- rescue Errno::EEXIST
- raise PathError, "Could not install to path `#{Bundler.settings[:path]}` " +
- "because of an invalid symlink. Remove the symlink so the directory can be created."
- end
+ create_bundle_path
if Bundler.settings[:frozen]
@definition.ensure_equivalent_gemfile_and_lockfile(options[:deployment])
@@ -325,5 +319,13 @@ module Bundler
remains[dep.name]
end
end
+
+ def create_bundle_path
+ Bundler.mkdir_p(Bundler.bundle_path.to_s) unless Bundler.bundle_path.exist?
+ rescue Errno::EEXIST
+ raise PathError, "Could not install to path `#{Bundler.settings[:path]}` " +
+ "because of an invalid symlink. Remove the symlink so the directory can be created."
+ end
+
end
end
diff --git a/spec/install/gems/sudo_spec.rb b/spec/install/gems/sudo_spec.rb
index 7ff564c476..4985fafd3c 100644
--- a/spec/install/gems/sudo_spec.rb
+++ b/spec/install/gems/sudo_spec.rb
@@ -66,7 +66,22 @@ describe "when using sudo", :sudo => true do
should_be_installed "rack 1.0"
end
- it "installs when BUNDLE_PATH does not exist"
+ it "installs when BUNDLE_PATH does not exist" do
+ root_path = tmp("owned_by_root")
+ FileUtils.mkdir_p root_path
+ sudo "chown -R root #{root_path}"
+ bundle_path = root_path.join("does_not_exist")
+
+ ENV['BUNDLE_PATH'] = bundle_path.to_s
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack", '1.0'
+ G
+
+ expect(bundle_path.join("gems/rack-1.0.0")).to exist
+ expect(bundle_path.join("gems/rack-1.0.0").stat.uid).to eq(0)
+ should_be_installed "rack 1.0"
+ end
end
describe "and BUNDLE_PATH is not writable" do