Permalink
Browse files

sensible error when dead symlinks are passed to --path, with a test

  • Loading branch information...
indirect committed Apr 12, 2011
1 parent 4690616 commit 97ae52e949489b86437f7a6cf97222443d60a361
Showing with 26 additions and 3 deletions.
  1. +8 −3 lib/bundler/installer.rb
  2. +18 −0 spec/install/invalid_spec.rb
View
@@ -10,6 +10,14 @@ def self.install(root, definition, options = {})
end
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
+
if Bundler.settings[:frozen]
@definition.ensure_equivalent_gemfile_and_lockfile(options[:deployment])
end
@@ -35,9 +43,6 @@ def run(options)
@definition.resolve_remotely!
end
- # Ensure that BUNDLE_PATH exists
- Bundler.mkdir_p(Bundler.bundle_path) unless File.exist?(Bundler.bundle_path)
-
# Must install gems in the order that the resolver provides
# as dependencies might actually affect the installation of
# the gem.
@@ -15,3 +15,21 @@
end
end
+
+describe "bundle install to a dead symlink" do
+ before do
+ in_app_root do
+ `ln -s /tmp/idontexist bundle`
+ end
+ end
+
+ fit "reports the symlink is dead" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+
+ bundle "install --path bundle"
+ out.should =~ /invalid symlink/
+ end
+end

0 comments on commit 97ae52e

Please sign in to comment.