[BUG] in FileUtils.cp_r *not* replacing read-only files

Hi everyone,

I'm porting some ruby code from MacOS to Windows XP. The code works fine on the
Mac, but not on Windows as you can see.

This is the code that's causing the error (line 278 of buildwebclient.rb):

  FileUtils.cp_r("#{$html_template_path}/.", "#{$build_destination_path}", :preserve => true, :verbose=> true, :remove_destination => true)

Please note: The reason I use the remove_destination option is because the source
and target files are read-only. This behaves as I would expect on the Mac.

The is the log of the error:

  cp -rp --remove-destination C:\Projects/rnd/WebClient/RELEASE/Source/MindjetConnect/html-template/. C:\Projects/rnd/WebClient/RELEASE/BuiltVersions/WebClient_1.0.74
  An exception caused the build script to fail:
  Permission denied - C:\Projects/rnd/WebClient/RELEASE/BuiltVersions/WebClient_1.0.74/.
  c:/ruby/lib/ruby/1.8/fileutils.rb:1270:in `utime'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1270:in `copy_metadata'
  c:/ruby/lib/ruby/1.8/fileutils.rb:452:in `copy_entry'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1324:in `traverse'
  c:/ruby/lib/ruby/1.8/fileutils.rb:448:in `copy_entry'
  c:/ruby/lib/ruby/1.8/fileutils.rb:423:in `cp_r'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1395:in `fu_each_src_dest'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1409:in `fu_each_src_dest0'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1393:in `fu_each_src_dest'
  c:/ruby/lib/ruby/1.8/fileutils.rb:422:in `cp_r'
  buildwebclient.rb:278

The version of ruby on XP is:

  ruby 1.8.6 (2008-03-03 patchlevel 114) [i386-mswin32]

On the Mac, it's:

  ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0]

I would use FileUtils.cp :force but that means I'd have to know every single file and
directory that I'm copying -- I don't want to have to maintain such a list.

Any ideas? Known issue?

Thanks.

CB

Could it be the C:\.../.../ sillyness?

···

On Apr 25, 9:41 am, cb <exam...@example.com> wrote:

Hi everyone,

I'm porting some ruby code from MacOS to Windows XP. The code works fine on the
Mac, but not on Windows as you can see.

This is the code that's causing the error (line 278 of buildwebclient.rb):

  FileUtils.cp_r("#{$html_template_path}/.", "#{$build_destination_path}", :preserve => true, :verbose=> true, :remove_destination => true)

Please note: The reason I use the remove_destination option is because the source
and target files are read-only. This behaves as I would expect on the Mac.

The is the log of the error:

  cp -rp --remove-destination C:\Projects/rnd/WebClient/RELEASE/Source/MindjetConnect/html-template/. C:\Projects/rnd/WebClient/RELEASE/BuiltVersions/WebClient_1.0.74
  An exception caused the build script to fail:
  Permission denied - C:\Projects/rnd/WebClient/RELEASE/BuiltVersions/WebClient_1.0.74/.
  c:/ruby/lib/ruby/1.8/fileutils.rb:1270:in `utime'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1270:in `copy_metadata'
  c:/ruby/lib/ruby/1.8/fileutils.rb:452:in `copy_entry'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1324:in `traverse'
  c:/ruby/lib/ruby/1.8/fileutils.rb:448:in `copy_entry'
  c:/ruby/lib/ruby/1.8/fileutils.rb:423:in `cp_r'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1395:in `fu_each_src_dest'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1409:in `fu_each_src_dest0'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1393:in `fu_each_src_dest'
  c:/ruby/lib/ruby/1.8/fileutils.rb:422:in `cp_r'
  buildwebclient.rb:278

The version of ruby on XP is:

  ruby 1.8.6 (2008-03-03 patchlevel 114) [i386-mswin32]

On the Mac, it's:

  ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0]

I would use FileUtils.cp :force but that means I'd have to know every single file and
directory that I'm copying -- I don't want to have to maintain such a list.

Any ideas? Known issue?

Thanks.

CB

Nope, that doesn't help. Nor does removing the "C:".

···

On Fri, 25 Apr 2008 12:45:16 -0700 (PDT), John <john.d.perkins@gmail.com> wrote:

On Apr 25, 9:41 am, cb <exam...@example.com> wrote:

Hi everyone,

I'm porting some ruby code from MacOS to Windows XP. The code works fine on the
Mac, but not on Windows as you can see.

This is the code that's causing the error (line 278 of buildwebclient.rb):

  FileUtils.cp_r("#{$html_template_path}/.", "#{$build_destination_path}", :preserve => true, :verbose=> true, :remove_destination => true)

Please note: The reason I use the remove_destination option is because the source
and target files are read-only. This behaves as I would expect on the Mac.

The is the log of the error:

  cp -rp --remove-destination C:\Projects/rnd/WebClient/RELEASE/Source/MindjetConnect/html-template/. C:\Projects/rnd/WebClient/RELEASE/BuiltVersions/WebClient_1.0.74
  An exception caused the build script to fail:
  Permission denied - C:\Projects/rnd/WebClient/RELEASE/BuiltVersions/WebClient_1.0.74/.
  c:/ruby/lib/ruby/1.8/fileutils.rb:1270:in `utime'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1270:in `copy_metadata'
  c:/ruby/lib/ruby/1.8/fileutils.rb:452:in `copy_entry'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1324:in `traverse'
  c:/ruby/lib/ruby/1.8/fileutils.rb:448:in `copy_entry'
  c:/ruby/lib/ruby/1.8/fileutils.rb:423:in `cp_r'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1395:in `fu_each_src_dest'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1409:in `fu_each_src_dest0'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1393:in `fu_each_src_dest'
  c:/ruby/lib/ruby/1.8/fileutils.rb:422:in `cp_r'
  buildwebclient.rb:278

The version of ruby on XP is:

  ruby 1.8.6 (2008-03-03 patchlevel 114) [i386-mswin32]

On the Mac, it's:

  ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0]

I would use FileUtils.cp :force but that means I'd have to know every single file and
directory that I'm copying -- I don't want to have to maintain such a list.

Any ideas? Known issue?

Thanks.

CB

Could it be the C:\.../.../ sillyness?

Nope, that doesn't help. Nor does removing the "C:".

c:/ruby/lib/ruby/1.8/fileutils.rb:1270:in `utime' is a good start. It
may be part of the way windowsxp handles times on files - I don't
really know to be honest, but I would start by looking at line 1270 of
ruby/lib/ruby/1.8/fileutils.rb

>> Hi everyone,

>> I'm porting some ruby code from MacOS to Windows XP. The code works fine on the
>> Mac, but not on Windows as you can see.

>> This is the code that's causing the error (line 278 of buildwebclient.rb):

>> FileUtils.cp_r("#{$html_template_path}/.", "#{$build_destination_path}", :preserve => true, :verbose=> true, :remove_destination => true)

>> Please note: The reason I use the remove_destination option is because the source
>> and target files are read-only. This behaves as I would expect on the Mac.

>> The is the log of the error:

>> cp -rp --remove-destination C:\Projects/rnd/WebClient/RELEASE/Source/MindjetConnect/html-template/. C:\Projects/rnd/WebClient/RELEASE/BuiltVersions/WebClient_1.0.74
>> An exception caused the build script to fail:
>> Permission denied - C:\Projects/rnd/WebClient/RELEASE/BuiltVersions/WebClient_1.0.74/.
>> c:/ruby/lib/ruby/1.8/fileutils.rb:1270:in `utime'
>> c:/ruby/lib/ruby/1.8/fileutils.rb:1270:in `copy_metadata'
>> c:/ruby/lib/ruby/1.8/fileutils.rb:452:in `copy_entry'
>> c:/ruby/lib/ruby/1.8/fileutils.rb:1324:in `traverse'
>> c:/ruby/lib/ruby/1.8/fileutils.rb:448:in `copy_entry'
>> c:/ruby/lib/ruby/1.8/fileutils.rb:423:in `cp_r'
>> c:/ruby/lib/ruby/1.8/fileutils.rb:1395:in `fu_each_src_dest'
>> c:/ruby/lib/ruby/1.8/fileutils.rb:1409:in `fu_each_src_dest0'
>> c:/ruby/lib/ruby/1.8/fileutils.rb:1393:in `fu_each_src_dest'
>> c:/ruby/lib/ruby/1.8/fileutils.rb:422:in `cp_r'
>> buildwebclient.rb:278

>> The version of ruby on XP is:

>> ruby 1.8.6 (2008-03-03 patchlevel 114) [i386-mswin32]

>> On the Mac, it's:

>> ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0]

>> I would use FileUtils.cp :force but that means I'd have to know every single file and
>> directory that I'm copying -- I don't want to have to maintain such a list.

>> Any ideas? Known issue?

>> Thanks.

>> CB

>Could it be the C:\.../.../ sillyness?

Nope, that doesn't help. Nor does removing the "C:".

Is a file from C:\Projects/rnd/WebClient/RELEASE/BuiltVersions/
WebClient_1.0.74/ loaded by you or another process? Windows don't let
you remove a file that is locked by any process.

Is the file generated by you or by another process? there could apply
some ACL rules taht can be limiting that functionality.

Besides that, attrib +r on these files worked for me:

mkdir foo
mkdir bar
echo A > foo\test
copy foo\test bar\test
attrib +r foo\test
attrib +r bar\test
ruby -rfileutils -e "FileUtils.cp_r('foo/.', 'bar', :preserve => true, :verbose => true, :remove_destination => true)"

cp -rp --remove-destination foo/. bar

HTH,

···

On Apr 25, 6:11 pm, cb <exam...@example.com> wrote:

On Fri, 25 Apr 2008 12:45:16 -0700 (PDT), John <john.d.perk...@gmail.com> wrote:
>On Apr 25, 9:41 am, cb <exam...@example.com> wrote:

--
Luis Lavena

Well, I never solved the specific problem. I worked around it by removing the :preserve option.

Thanks for the help.

CB

···

On Fri, 25 Apr 2008 14:11:20 -0700, cb <example@example.com> wrote:

On Fri, 25 Apr 2008 12:45:16 -0700 (PDT), John <john.d.perkins@gmail.com> wrote:

On Apr 25, 9:41 am, cb <exam...@example.com> wrote:

Hi everyone,

I'm porting some ruby code from MacOS to Windows XP. The code works fine on the
Mac, but not on Windows as you can see.

This is the code that's causing the error (line 278 of buildwebclient.rb):

  FileUtils.cp_r("#{$html_template_path}/.", "#{$build_destination_path}", :preserve => true, :verbose=> true, :remove_destination => true)

Please note: The reason I use the remove_destination option is because the source
and target files are read-only. This behaves as I would expect on the Mac.

The is the log of the error:

  cp -rp --remove-destination C:\Projects/rnd/WebClient/RELEASE/Source/MindjetConnect/html-template/. C:\Projects/rnd/WebClient/RELEASE/BuiltVersions/WebClient_1.0.74
  An exception caused the build script to fail:
  Permission denied - C:\Projects/rnd/WebClient/RELEASE/BuiltVersions/WebClient_1.0.74/.
  c:/ruby/lib/ruby/1.8/fileutils.rb:1270:in `utime'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1270:in `copy_metadata'
  c:/ruby/lib/ruby/1.8/fileutils.rb:452:in `copy_entry'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1324:in `traverse'
  c:/ruby/lib/ruby/1.8/fileutils.rb:448:in `copy_entry'
  c:/ruby/lib/ruby/1.8/fileutils.rb:423:in `cp_r'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1395:in `fu_each_src_dest'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1409:in `fu_each_src_dest0'
  c:/ruby/lib/ruby/1.8/fileutils.rb:1393:in `fu_each_src_dest'
  c:/ruby/lib/ruby/1.8/fileutils.rb:422:in `cp_r'
  buildwebclient.rb:278

The version of ruby on XP is:

  ruby 1.8.6 (2008-03-03 patchlevel 114) [i386-mswin32]

On the Mac, it's:

  ruby 1.8.6 (2007-09-24 patchlevel 111) [universal-darwin9.0]

I would use FileUtils.cp :force but that means I'd have to know every single file and
directory that I'm copying -- I don't want to have to maintain such a list.

Any ideas? Known issue?

Thanks.

CB

Could it be the C:\.../.../ sillyness?

Nope, that doesn't help. Nor does removing the "C:".