summaryrefslogtreecommitdiff
path: root/lib/rubygems/installer.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/rubygems/installer.rb')
-rw-r--r--lib/rubygems/installer.rb9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/rubygems/installer.rb b/lib/rubygems/installer.rb
index f4d3e728de..967543c2d1 100644
--- a/lib/rubygems/installer.rb
+++ b/lib/rubygems/installer.rb
@@ -214,7 +214,7 @@ class Gem::Installer
ruby_executable = true
existing = io.read.slice(%r{
- ^(
+ ^\s*(
gem \s |
load \s Gem\.bin_path\( |
load \s Gem\.activate_bin_path\(
@@ -701,6 +701,8 @@ class Gem::Installer
# Return the text for an application file.
def app_script_text(bin_file_name)
+ # note that the `load` lines cannot be indented, as old RG versions match
+ # against the beginning of the line
return <<-TEXT
#{shebang bin_file_name}
#
@@ -723,7 +725,12 @@ if ARGV.first
end
end
+if Gem.respond_to?(:activate_bin_path)
load Gem.activate_bin_path('#{spec.name}', '#{bin_file_name}', version)
+else
+gem #{spec.name.dump}, version
+load Gem.bin_path(#{spec.name.dump}, #{bin_file_name.dump}, version)
+end
TEXT
end