aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bundler.rb
diff options
context:
space:
mode:
authorDavid Rodríguez <deivid.rodriguez@riseup.net>2022-05-27 20:46:42 +0200
committergit <svn-admin@ruby-lang.org>2022-05-30 17:42:39 +0900
commitea31c5bcd1bc1a019a6aee2b3f3b16813d7ff96d (patch)
tree9a1ef608de38fbfa75e47adfa5264105ae13fd30 /lib/bundler.rb
parent0d7d8f3777b4521b2e83d81c0f830941bfba7b9c (diff)
downloadruby-ea31c5bcd1bc1a019a6aee2b3f3b16813d7ff96d.tar.gz
[rubygems/rubygems] Fix crash when installing gems with symlinks
If BUNDLE_PATH is configured to a symlinked path, installing gems with symlinks would crash with an error like this: ``` Gem::Package::SymlinkError: installing symlink 'man/man0/README.markdown' pointing to parent path /usr/home/stevewi/srv/mail/lib/tools/.vendor/ruby/3.1.0/gems/binman-5.1.0/README.markdown of /srv/mail/lib/tools/.vendor/ruby/3.1.0/gems/binman-5.1.0 is not allowed ``` This commit fixes the problem by changing the bundle path to be the realpath of the configured value, right after we're sure the path has been created. https://github.com/rubygems/rubygems/commit/3cd3dd142a
Diffstat (limited to 'lib/bundler.rb')
-rw-r--r--lib/bundler.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 0be01d1808..c99114ae64 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -97,6 +97,17 @@ module Bundler
@bundle_path ||= Pathname.new(configured_bundle_path.path).expand_path(root)
end
+ def create_bundle_path
+ SharedHelpers.filesystem_access(bundle_path.to_s) do |p|
+ mkdir_p(p)
+ end unless bundle_path.exist?
+
+ @bundle_path = bundle_path.realpath
+ rescue Errno::EEXIST
+ raise PathError, "Could not install to path `#{bundle_path}` " \
+ "because a file already exists at that path. Either remove or rename the file so the directory can be created."
+ end
+
def configured_bundle_path
@configured_bundle_path ||= settings.path.tap(&:validate!)
end