Discussion:
Rake 0.8.7 broken on Windows
Hartin, Brian
2010-05-26 20:42:29 UTC
Permalink
Hi all,

In Rake::AltSystem#repair_command, you're now appending "call " to the
beginning of the command. This has the effect of losing the working
directory. For example, running 'rake test' from the root directory of
a project will fail to find its unit tests. It also causes a lot of gem
installation failures, as 'gem install' often seems to run rake from the
installed gem directory to complete the installation, and fails to find
necessary files.

This is not backward compatible, obviously.

1 - Is there a workaround?

2 - Why is the 'call' necessary? Is this part of preserving the linux
'sh' semantics you mentioned? If so, how would one avoid this problem
in linux?

Thanks,

Brian Hartin
Luis Lavena
2010-05-26 21:15:20 UTC
Permalink
Post by Hartin, Brian
Hi all,
In Rake::AltSystem#repair_command, you're now appending "call " to the
beginning of the command.  This has the effect of losing the working
directory.  For example, running 'rake test' from the root directory of
a project will fail to find its unit tests.  It also causes a lot of gem
installation failures, as 'gem install' often seems to run rake from the
installed gem directory to complete the installation, and fails to find
necessary files.
Can you give a concrete example? GitHub repo that can be cloned and see this?

I've been using Rake 0.8.7 with 1.8.6, 1.8.7 without issues. 1.9.1 has
fixed the system invocations and works to for gem installation and
everything.

Please provide us more information so we can help determine the real
root of the issue.

Call preserves the parent process path:

C:\Users\Luis>cd && cd Desktop && cd && call cmd.exe /c cd && cd .. && cd
C:\Users\Luis
C:\Users\Luis\Desktop
C:\Users\Luis\Desktop
C:\Users\Luis

That is true for Ruby too.
--
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
Hartin, Brian
2010-05-26 22:17:46 UTC
Permalink
Luis,

I have created three one-line ruby scripts to demonstrate the issue with 'call'. Please note the directory locations:

c:\temp\print_working_directory.rb:

puts "Working directory is #{Dir.pwd}"

c:\temp\invoke_ruby.rb

Kernel.system('c:\ruby\bin\ruby.exe c:\temp\print_working_directory.rb')

c:\temp\invoke_ruby_using_call.rb

Kernel.system('call c:\ruby\bin\ruby.exe c:\temp\print_working_directory.rb')

Next, I opened a command window and executed the following commands:

c:\>cd c:\temp
c:\temp>ruby invoke_ruby.rb (prints "Working directory is C:/temp")
c:\temp>ruby invoke_ruby_using_call.rb (prints "Working directory is C:/Documents and Settings/hartbr")


When I run 'rake test' from my project directory (C:\workspaces\project), I see the same thing. To demonstrate, here's what you need to do:

1) gem install rake 0.7.3
2) Modify rake_test_loader.rb to print the working directory.
3) Run 'rake:test' from the root directory of any Rails project. You should see that the forked ruby process runs the tests from that directory.
4) Uninstall rake 0.7.3 (Just for clarity's sake)
5) Install rake 0.8.7
6) Repeat step 2
7) Repeat step 3, and I think it will fail to find the unit tests.

I traced things from the Rails rake tasks all the way to alt_system.rb, and this doesn't seem to be a Rails issue. Rails correctly assembles the file list, consisting of relative paths like "test/unit/foo_test.rb". The directory issue causes Rake 0.8.7 to fail with a "No such file to load" error.

I did a fresh install of Ruby today, to make sure my Ruby installation wasn't part of the problem.

Thanks,

Brian
-----Original Message-----
Sent: Wednesday, May 26, 2010 4:15 PM
To: Rake Development and Discussion
Subject: Re: [Rake-devel] Rake 0.8.7 broken on Windows
On Wed, May 26, 2010 at 5:42 PM, Hartin, Brian
Post by Hartin, Brian
Hi all,
In Rake::AltSystem#repair_command, you're now appending
"call " to the
Post by Hartin, Brian
beginning of the command.  This has the effect of losing the working
directory.  For example, running 'rake test' from the root
directory of
Post by Hartin, Brian
a project will fail to find its unit tests.  It also causes
a lot of gem
Post by Hartin, Brian
installation failures, as 'gem install' often seems to run
rake from the
Post by Hartin, Brian
installed gem directory to complete the installation, and
fails to find
Post by Hartin, Brian
necessary files.
Can you give a concrete example? GitHub repo that can be
cloned and see this?
I've been using Rake 0.8.7 with 1.8.6, 1.8.7 without issues. 1.9.1 has
fixed the system invocations and works to for gem installation and
everything.
Please provide us more information so we can help determine the real
root of the issue.
C:\Users\Luis>cd && cd Desktop && cd && call cmd.exe /c cd &&
cd .. && cd
C:\Users\Luis
C:\Users\Luis\Desktop
C:\Users\Luis\Desktop
C:\Users\Luis
That is true for Ruby too.
--
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
_______________________________________________
Rake-devel mailing list
http://rubyforge.org/mailman/listinfo/rake-devel
Luis Lavena
2010-05-26 22:42:47 UTC
Permalink
Luis,
       puts "Working directory is #{Dir.pwd}"
c:\temp\invoke_ruby.rb
       Kernel.system('c:\ruby\bin\ruby.exe c:\temp\print_working_directory.rb')
c:\temp\invoke_ruby_using_call.rb
       Kernel.system('call c:\ruby\bin\ruby.exe c:\temp\print_working_directory.rb')
       c:\>cd c:\temp
       c:\temp>ruby invoke_ruby.rb (prints "Working directory is C:/temp")
       c:\temp>ruby invoke_ruby_using_call.rb (prints "Working directory is C:/Documents and Settings/hartbr")
1) gem install rake 0.7.3
2) Modify rake_test_loader.rb to print the working directory.
3) Run 'rake:test' from the root directory of any Rails project.  You should see that the forked ruby process runs the tests from that directory.
4) Uninstall rake 0.7.3 (Just for clarity's sake)
5) Install rake 0.8.7
6) Repeat step 2
7) Repeat step 3, and I think it will fail to find the unit tests.
I traced things from the Rails rake tasks all the way to alt_system.rb, and this doesn't seem to be a Rails issue.  Rails correctly assembles the file list, consisting of relative paths like "test/unit/foo_test.rb".  The directory issue causes Rake 0.8.7 to fail with a "No such file to load" error.
I did a fresh install of Ruby today, to make sure my Ruby installation wasn't part of the problem.
The only one reporting me "No such file to load" is Ruby 1.9.2 that do
not add "." to the $LOAD_PATH

Invoking "rake test" or "rake spec" in any project I've used takes the
directory where Rakefile is found and executed.

That had worked and still works for me.

There was several back and forth on alt_system issues because Ruby
1.8.x is flawed to handle system calls. "call" was required to handle
*args calls to system.
--
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
Hartin, Brian
2010-05-27 17:39:26 UTC
Permalink
Luis,

Thanks for your help. There does indeed seem to be something wrong on my end. Kernel.system('call ...') executes in a different directory than Kernel.system('...'), but for my co-worker, it does not. We have the exact same version of ruby, too.

Brian
-----Original Message-----
Sent: Wednesday, May 26, 2010 5:43 PM
To: Rake Development and Discussion
Subject: Re: [Rake-devel] Rake 0.8.7 broken on Windows
On Wed, May 26, 2010 at 7:17 PM, Hartin, Brian
Post by Hartin, Brian
Luis,
I have created three one-line ruby scripts to demonstrate
       puts "Working directory is #{Dir.pwd}"
c:\temp\invoke_ruby.rb
       Kernel.system('c:\ruby\bin\ruby.exe
c:\temp\print_working_directory.rb')
Post by Hartin, Brian
c:\temp\invoke_ruby_using_call.rb
       Kernel.system('call c:\ruby\bin\ruby.exe
c:\temp\print_working_directory.rb')
Post by Hartin, Brian
       c:\>cd c:\temp
       c:\temp>ruby invoke_ruby.rb (prints "Working
directory is C:/temp")
Post by Hartin, Brian
       c:\temp>ruby invoke_ruby_using_call.rb (prints
"Working directory is C:/Documents and Settings/hartbr")
Post by Hartin, Brian
When I run 'rake test' from my project directory
(C:\workspaces\project), I see the same thing.  To
Post by Hartin, Brian
1) gem install rake 0.7.3
2) Modify rake_test_loader.rb to print the working directory.
3) Run 'rake:test' from the root directory of any Rails
project.  You should see that the forked ruby process runs
the tests from that directory.
Post by Hartin, Brian
4) Uninstall rake 0.7.3 (Just for clarity's sake)
5) Install rake 0.8.7
6) Repeat step 2
7) Repeat step 3, and I think it will fail to find the unit tests.
I traced things from the Rails rake tasks all the way to
alt_system.rb, and this doesn't seem to be a Rails issue.  
Rails correctly assembles the file list, consisting of
relative paths like "test/unit/foo_test.rb".  The directory
issue causes Rake 0.8.7 to fail with a "No such file to load" error.
Post by Hartin, Brian
I did a fresh install of Ruby today, to make sure my Ruby
installation wasn't part of the problem.
The only one reporting me "No such file to load" is Ruby 1.9.2 that do
not add "." to the $LOAD_PATH
Invoking "rake test" or "rake spec" in any project I've used takes the
directory where Rakefile is found and executed.
That had worked and still works for me.
There was several back and forth on alt_system issues because Ruby
1.8.x is flawed to handle system calls. "call" was required to handle
*args calls to system.
--
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
_______________________________________________
Rake-devel mailing list
http://rubyforge.org/mailman/listinfo/rake-devel
Loading...