Skip to content

Instantly share code, notes, and snippets.

@lsegal
Created June 11, 2009 22:17
Show Gist options
  • Save lsegal/128272 to your computer and use it in GitHub Desktop.
Save lsegal/128272 to your computer and use it in GitHub Desktop.
Make RubyGems generate sane binaries that work for ruby18 and ruby19
--- a/lib/rubygems/installer.rb 2009-05-02 18:53:50.000000000 -0400
+++ b/lib/rubygems/installer.rb 2009-06-11 16:25:33.000000000 -0400
@@ -397,14 +397,19 @@
else
path = File.join @gem_dir, @spec.bindir, bin_file_name
+ ruby_bin_file = File.join(File.dirname(Gem.ruby), 'ruby')
+ unless File.symlink?(ruby_bin_file)
+ ruby_bin_file = Gem.ruby
+ end
+
File.open(path, "rb") do |file|
first_line = file.gets
if first_line =~ /^#!/ then
# Preserve extra words on shebang line, like "-w". Thanks RPA.
- shebang = first_line.sub(/\A\#!.*?ruby\S*/, "#!#{Gem.ruby}")
+ shebang = first_line.sub(/\A\#!.*?ruby\S*/, "#!#{ruby_bin_file}")
else
# Create a plain shebang line.
- shebang = "#!#{Gem.ruby}"
+ shebang = "#!#{ruby_bin_file}"
end
shebang.strip # Avoid nasty ^M issues.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment