diff --git a/lib/rubygems/package.rb b/lib/rubygems/package.rb
index 9ed5b2c9ed..13eb25bd26 100644
--- a/lib/rubygems/package.rb
+++ b/lib/rubygems/package.rb
@@ -371,6 +371,8 @@ EOM
File.respond_to? :realpath
destination = File.join destination_dir, filename
+ destination = File.realpath destination if
+ File.respond_to? :realpath
destination = File.expand_path destination
raise Gem::Package::PathError.new(destination, destination_dir) unless
--
2.20.1