Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Problems with FileUtils in Rake

Reply
Thread Tools

Problems with FileUtils in Rake

 
 
Charles Comstock
Guest
Posts: n/a
 
      06-19-2004
Why is it that the following rakefile code works:

task :examples do
sh %{rm -rf ~/.ruby_inline}
ruby %{-Ilib/inline.rb -w bench/example.rb}
sh %{rm -rf ~/.ruby_inline}
ruby %{-Ilib/inline.rb -w bench/example2.rb}
sh %{rm -rf ~/.ruby_inline}
ruby %{-Ilib/inline.rb -w tutorial/example1.rb}
sh %{rm -rf ~/.ruby_inline}
ruby %{-Ilib/inline.rb -w tutorial/example2.rb}
end

produces valid output of:

[761 cc1@earwig ~/install/RubyInline-3.0.1]$ rake examples
(in /.autofs/home/s/c/cc1/install/RubyInline-3.0.1)
rm -rf ~/.ruby_inline
ruby -Ilib/inline.rb -w bench/example.rb
Type = Inline C , Iter = 1000000, T = 1.59424400 sec, 0.00000159 sec / iter
rm -rf ~/.ruby_inline
ruby -Ilib/inline.rb -w bench/example2.rb
hello
hello
hello
rm -rf ~/.ruby_inline
ruby -Ilib/inline.rb -w tutorial/example1.rb
......
rm -rf ~/.ruby_inline
ruby -Ilib/inline.rb -w tutorial/example2.rb
......


but

task :examples do
rm_rf %{~/.ruby_inline}
ruby %{-Ilib/inline.rb -w bench/example.rb}
rm_rf %{~/.ruby_inline}
ruby %{-Ilib/inline.rb -w bench/example2.rb}
rm_rf %{~/.ruby_inline}
ruby %{-Ilib/inline.rb -w tutorial/example1.rb}
rm_rf %{~/.ruby_inline}
ruby %{-Ilib/inline.rb -w tutorial/example2.rb}
end

produces:

[762 cc1@earwig ~/install/RubyInline-3.0.1]$ rake examples
(in /.autofs/home/s/c/cc1/install/RubyInline-3.0.1)
rm -rf ~/.ruby_inline
ruby -Ilib/inline.rb -w bench/example.rb
Type = Inline C , Iter = 1000000, T = 1.83316400 sec, 0.00000183 sec / iter
rm -rf ~/.ruby_inline
ruby -Ilib/inline.rb -w bench/example2.rb
bench/example2.rb:29: undefined method `hello' for #<MyTest:0x4007fa00>
(NoMethodError)
rake aborted!
Command Failed: [ruby -Ilib/inline.rb -w bench/example2.rb]
../Rakefile:61

both of these tests are using:

ruby 1.8.2 (2004-06-04) [i686-linux]

My assumption is that FileUtils.rm_rf is not actually doing it's job.
This is validated by the fact that ~/.ruby_inline does not appear to be
correctly deleted in the second example.

So why is it FileUtils.rm_rf is not doing it's job when it should just
call through to rm -rf?

Charles Comstock
 
Reply With Quote
 
 
 
 
nobu.nokada@softhome.net
Guest
Posts: n/a
 
      06-19-2004
Hi,

At Sat, 19 Jun 2004 17:38:20 +0900,
Charles Comstock wrote in [ruby-talk:104116]:
> task :examples do
> rm_rf %{~/.ruby_inline}


rm_rf File.expand_path(%{~/.ruby_inline})

FileUtils itself doesn't do tilde-expansion.

--
Nobu Nakada


 
Reply With Quote
 
 
 
 
Charles Comstock
Guest
Posts: n/a
 
      06-19-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:

> Hi,
>
> At Sat, 19 Jun 2004 17:38:20 +0900,
> Charles Comstock wrote in [ruby-talk:104116]:
>
>>task :examples do
>> rm_rf %{~/.ruby_inline}

>
>
> rm_rf File.expand_path(%{~/.ruby_inline})
>
> FileUtils itself doesn't do tilde-expansion.
>


Ah. Hmm. Is there a way to force it to do tilde expansion if the
functionality is available? The application won't work without posix
support anyway, so isn't this something we could assume? Or is that an
unfair assumption? What is the preferred way to deal with this?

Charles Comstock
 
Reply With Quote
 
nobu.nokada@softhome.net
Guest
Posts: n/a
 
      06-19-2004
Hi,

At Sat, 19 Jun 2004 19:03:20 +0900,
Charles Comstock wrote in [ruby-talk:104118]:
> >>task :examples do
> >> rm_rf %{~/.ruby_inline}

> >
> >
> > rm_rf File.expand_path(%{~/.ruby_inline})
> >
> > FileUtils itself doesn't do tilde-expansion.
> >

>
> Ah. Hmm. Is there a way to force it to do tilde expansion if the
> functionality is available? The application won't work without posix
> support anyway, so isn't this something we could assume? Or is that an
> unfair assumption? What is the preferred way to deal with this?


Which application do you mention about, Rake?

Including this module may work, instead of FileUtils:

module Tilde
module_function
def rm_rf(*args)
args.collect!{|n|File.expand_path(n) rescue break}
FileUtils.rm_rf(*args)
end
end

--
Nobu Nakada


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
rake published rdoc version and arity of Rake::Task#execute - wrongnumber of arguments (0 for 1) James Mead Ruby 0 01-15-2008 05:42 PM
Rake TestTask running its block anytime rake is invoked Adam Anderson Ruby 1 09-19-2007 08:40 AM
rake + FileUtils == warining Ronald Fischer Ruby 4 08-31-2007 07:24 AM
Rake and rake aborted! Rake aborted! undefined method `gem' for main:Object peppermonkey Ruby 1 02-10-2007 04:43 AM
Rake 0.7.0 breaks "rake engine_migrate"? Joe Van Dyk Ruby 2 01-31-2006 12:11 AM



Advertisments