Project

General

Profile

Bug #1010

Ruby-1.9's rake sh doesn't work on Windows (but fix provided)

Added by Chauk-Mean (Chauk-Mean Proum) over 10 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
ruby -v:
Backport:
[ruby-core:21339]

Description

=begin
Hi,

I'm reporting this issue in Rake as rake is now part of Ruby-1.9 and this problem affects only Ruby-1.9.

For Windows, FileUtils#sh (in rake.rb) calls Rake::Win32.rake_system (in rake/win32.rb) defined as :

def rake_system(*cmd)
if cmd.size == 1
system("call #{cmd}") # The problem is here with ruby-1.9
else
system(*cmd)
end
end

With ruby-1.9 on Windows :
sh "my_foo_command"
will result in
call ["my_foo_command"]
which will result in syntax error due to [ and ].

With ruby-1.8, the result is :
call my_foo_command

The fix is simple : replace the "call #{cmd}" with "call #{cmd[0]}"

def rake_system(*cmd)
if cmd.size == 1
system("call #{cmd[0]}") # fix for 1.9 but works fine with 1.8
else
system(*cmd)
end
end

Chauk-Mean.
=end

History

#1

Updated by luislavena (Luis Lavena) over 10 years ago

=begin
Yes, this is already been discussed in Rake mailing list and a workaround the broken system() call was addressed.

http://rubyforge.org/pipermail/rake-devel/2008-November/000673.html

I believe Jim Weirich needs to bring those changes back into the repository.
=end

#2

Updated by Chauk-Mean (Chauk-Mean Proum) over 10 years ago

=begin

Following the thread on the rake mailing list (http://rubyforge.org/pipermail/rake-devel/2008-November/000673.html), it seems that Kernel#system on Windows handles or may handle correctly multiple arguments.
I guess that the call to system with a single argument will be removed and thus the specific ruby-1.9 issue I reported will disappear.

I hope that Jim Weirich will be able to integrate the corresponding changes for ruby-1.9.1 release.
Otherwise, my simple fix should be considered as a temporary workaround and committed for this release.

Chauk-Mean.

=end

#3

Updated by yugui (Yuki Sonoda) over 10 years ago

  • Due date set to 01/20/2009
  • Category set to lib

=begin
Is the fix for this problem d704fbeecad3fb02ca4a7f88ba21976f9d4d7f0e..5ace1fd87ab4a51a79e4599693ce6b081b1b3ae1 ?

Could you merge the fix to Ruby's trunk? < Jim Weirich
=end

#4

Updated by quix (James M. Lawrence) over 10 years ago

=begin

Is the fix for this problem
d704fbeecad3fb02ca4a7f88ba21976f9d4d7f0e..5ace1fd87ab4a51a79e4599693ce6b081b1b3ae1 ?
Could you merge the fix to Ruby's trunk? < Jim Weirich

No, those changes are obsolete now that bug #907 is resolved (system()
problems on Windows).

The latest fixes have been waiting in my branch, as mentioned on the
rake-devel list. The reported bug (#1010) no longer applies to 1.9,
while it is incidentally fixed in 1.8 due to my system() workarounds
for Windows.

I did not receive a response to my question on whether bug #907 will
be backported http://redmine.ruby-lang.org/issues/show/907.

On the rake-devel list I asked if Rake should to fix the system()
problems in 1.8, but there was no response.

Therefore my latest changes assume
(1) bug #907 will not be backported, and
(2) Jim wants Rake's sh to fix the system() problems in 1.8.

If (1) and (2), pull http://github.com/quix/rake/tree/mainline-rake

If (1) and not (2), follow the change described in this bug (#1010).

If not (1), we need to know which ruby version will have the backport
of #907.

=end

#5

Updated by yugui (Yuki Sonoda) over 10 years ago

  • Target version changed from 1.9.1 RC2 to 1.9.1

=begin

=end

#6

Updated by yugui (Yuki Sonoda) over 10 years ago

  • Target version deleted (1.9.1)

=begin

=end

#7

Updated by Chauk-Mean (Chauk-Mean Proum) over 10 years ago

=begin

So rake sh command will not work with Ruby 1.9.1 on Windows ?
I really don't understand why this issue has been removed for 1.9.1.
It's a pity as the fix I provided is very simple.

=end

#8

Updated by quix (James M. Lawrence) over 10 years ago

=begin
On Wed, Jan 28, 2009 at 10:22 AM, Luis Lavena luislavena@gmail.com wrote:

On Wed, Jan 28, 2009 at 1:15 PM, Chauk-Mean Proum redmine@ruby-lang.org wrote:

Issue #1010 has been updated by Chauk-Mean Proum.

So rake sh command will not work with Ruby 1.9.1 on Windows ?
I really don't understand why this issue has been removed for 1.9.1.
It's a pity as the fix I provided is very simple.

Ruby 1.9.1 has been fixed to workaround the issues described with
system(), but Rake source code that exist in ruby repository hasn't
been updated to reflect that change.

The merge from rake github repository into ruby subversion one is required.

Jim's github repository is still old. Don't merge it into svn.

The initial fix proposed in this bug report is also old. system("call
...") was there to expand variables and to handle extensionless files,
but that is now fixed inside ruby (#907).

Since Jim appears to be unavailable, I recommend that a commiter apply
this patch.

--- lib/rake/win32.rb (revision 21862)
+++ lib/rake/win32.rb (working copy)
@@ -12,16 +12,12 @@
class << self
# True if running on a windows system.
def windows?

  • Config::CONFIG['host_os'] =~ /mswin/
  •    Config::CONFIG['host_os'] =~ /mswin|mingw/
    end
    
    # Run a command line on windows.
    def rake_system(*cmd)
    
  •    if cmd.size == 1
    
  •      system("call #{cmd}")
    
  •    else
    
  •      system(*cmd)
    
  •    end
    
  •    system(*cmd)
    end
    
    # The standard directory containing system wide rake files on
    

=end

#9

Updated by nobu (Nobuyoshi Nakada) over 10 years ago

  • Status changed from Open to Closed
  • % Done changed from 0 to 100

=begin
Applied in changeset r21871.
=end

#10

Updated by luislavena (Luis Lavena) over 10 years ago

=begin
On Wed, Jan 28, 2009 at 1:15 PM, Chauk-Mean Proum redmine@ruby-lang.org wrote:

Issue #1010 has been updated by Chauk-Mean Proum.

So rake sh command will not work with Ruby 1.9.1 on Windows ?
I really don't understand why this issue has been removed for 1.9.1.
It's a pity as the fix I provided is very simple.

Ruby 1.9.1 has been fixed to workaround the issues described with
system(), but Rake source code that exist in ruby repository hasn't
been updated to reflect that change.

The merge from rake github repository into ruby subversion one is required.

--
Luis Lavena
AREA 17
-
Perfection in design is achieved not when there is nothing more to add,
but rather when there is nothing more to take away.
Antoine de Saint-Exupéry

=end

Also available in: Atom PDF