Skip to content

Commit 2d76d7b

Browse files
committed
Fall back to copy when File.symlink raises TypeError on Windows
Gem::Package#create_symlink already falls back to FileUtils.cp_r on Windows when symlink creation hits Errno::EACCES (Developer Mode off), but JRuby 10.1 surfaces the same failure as TypeError from its internal wincode path helper. Treat TypeError as the same recoverable condition so JRuby/Windows users extracting a tarball that ships symlinks get the copy fallback rather than a crash.
1 parent 88f5e29 commit 2d76d7b

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

lib/rubygems/package.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,9 +743,11 @@ def limit_read(io, name, limit)
743743
if Gem.win_platform?
744744
# Create a symlink and fallback to copy the file or directory on Windows,
745745
# where symlink creation needs special privileges in form of the Developer Mode.
746+
# JRuby on Windows raises TypeError from the wincode path-conversion helper
747+
# when it cannot create the symlink, so fall back to copy in that case too.
746748
def create_symlink(old_name, new_name)
747749
File.symlink(old_name, new_name)
748-
rescue Errno::EACCES
750+
rescue Errno::EACCES, TypeError
749751
from = File.expand_path(old_name, File.dirname(new_name))
750752
FileUtils.cp_r(from, new_name)
751753
end

0 commit comments

Comments
 (0)