[macruby-changes] [4521] MacRuby/trunk/lib/rubygems/installer.rb

source_changes at macosforge.org source_changes at macosforge.org
Fri Sep 17 01:31:14 PDT 2010


Revision: 4521
          http://trac.macosforge.org/projects/ruby/changeset/4521
Author:   watson1978 at gmail.com
Date:     2010-09-17 01:31:11 -0700 (Fri, 17 Sep 2010)
Log Message:
-----------
Should install the rubygems if file does not exist in /usr/bin/. Fixed #905.

Modified Paths:
--------------
    MacRuby/trunk/lib/rubygems/installer.rb

Modified: MacRuby/trunk/lib/rubygems/installer.rb
===================================================================
--- MacRuby/trunk/lib/rubygems/installer.rb	2010-09-16 21:39:50 UTC (rev 4520)
+++ MacRuby/trunk/lib/rubygems/installer.rb	2010-09-17 08:31:11 UTC (rev 4521)
@@ -325,13 +325,21 @@
       # FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers
 
       bin_script_exists = File.exists?(bin_script_path)
+      mode   = 'w' unless(bin_script_exists)
+      mode ||= 'r+'
       new_shebang = shebang(filename)
-      File.open bin_script_path, 'r+', 0755 do |file|
+      File.open bin_script_path, mode, 0755 do |file|
         if bin_script_exists
           # If the first line is different than the shebang we want to insert
           # we are probably overwriting a script installed by another ruby
           # implementation / version
-          if file.readline.chomp != new_shebang
+          begin
+            old_shebang = file.readline.chomp
+          rescue
+            old_shebang = ""
+          end
+
+          if old_shebang != new_shebang
             warn = <<-WARN_MESSAGE
 You are installing a new version of #{bin_script_path}.
 This file already exists with a different shebang, possibly from a different
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20100917/348345cf/attachment.html>


More information about the macruby-changes mailing list