ruby-dev (Japanese) list archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-dev:51020] [Ruby master Bug#17626] FileUtils.cp may cause utime_failed
@ 2021-02-13 11:48 agate.pris
  2021-02-13 13:25 ` [ruby-dev:51021] " xtkoba+ruby
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: agate.pris @ 2021-02-13 11:48 UTC (permalink / raw)
  To: ruby-dev

Issue #17626 has been reported by agate-pris (agate pris).

----------------------------------------
Bug #17626: FileUtils.cp may cause utime_failed
https://bugs.ruby-lang.org/issues/17626

* Author: agate-pris (agate pris)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x64-mingw32]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
FileUtils.cp will cause utime_failed if the file name contains Japanese characters and preserve is true.

This will probably only happen on Windows. It occures on Windows 10 version 2004 build 21301.1010.

``` ruby
require 'fileutils'

FileUtils.cp('foo', 'foo_copy', preserve: true)
FileUtils.cp('foo', 'fooコピー', preserve: true)
```

``` sh
$ ruby test.rb
C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1424:in `utime': No such file or directory @ utime_failed - fooコピー (Errno::ENOENT)
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1424:in `copy_metadata'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:515:in `copy_file'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:433:in `block in cp'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1597:in `block in fu_each_src_dest'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1613:in `fu_each_src_dest0'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1595:in `fu_each_src_dest'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:432:in `cp'
        from test.rb:4:in `<main>'
```

The expected result is copy to fooコピー is success same like copy to foo_copy.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-dev:51021] [Ruby master Bug#17626] FileUtils.cp may cause utime_failed
  2021-02-13 11:48 [ruby-dev:51020] [Ruby master Bug#17626] FileUtils.cp may cause utime_failed agate.pris
@ 2021-02-13 13:25 ` xtkoba+ruby
  2021-02-14  2:29 ` [ruby-dev:51022] " xtkoba+ruby
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: xtkoba+ruby @ 2021-02-13 13:25 UTC (permalink / raw)
  To: ruby-dev

Issue #17626 has been updated by xtkoba (Tee KOBAYASHI).


I compiled the following code by `x86_64-w64-mingw32-gcc`:
```
/* -*- coding: utf-8 -*- */
#include <stdio.h>
void touch(char *path) {
  FILE *file = fopen(path, "a");
  if (file != NULL) fclose(file);
}
int main() {
  touch("fooコピー");
  return 0;
}
```
and when I ran the output executable on Windows 10, I got a file with a funny name:
```
$ echo -n foo* | hexdump -C
00000000  66 6f 6f c3 a3 e2 80 9a  c2 b3 c3 a3 c6 92 e2 80  |foo.............|
00000010  9d c3 a3 c6 92 c2 bc                              |.......|
00000017
```

When I ran the following Ruby script in the directory where the funny file exists, then I got no errors:
```
// -*- coding: utf-8 -*-
File.utime 0, 0, "fooコピー"
```

I cannot summarize this phenomenon, but I think it has something to do with the main issue.

----------------------------------------
Bug #17626: FileUtils.cp may cause utime_failed
https://bugs.ruby-lang.org/issues/17626#change-90368

* Author: agate-pris (agate pris)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x64-mingw32]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
FileUtils.cp will cause utime_failed if the file name contains Japanese characters and preserve is true.

This will probably only happen on Windows. It occures on Windows 10 version 2004 build 21301.1010.

``` ruby
require 'fileutils'

FileUtils.cp('foo', 'foo_copy', preserve: true)
FileUtils.cp('foo', 'fooコピー', preserve: true)
```

``` sh
$ ruby test.rb
C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1424:in `utime': No such file or directory @ utime_failed - fooコピー (Errno::ENOENT)
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1424:in `copy_metadata'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:515:in `copy_file'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:433:in `block in cp'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1597:in `block in fu_each_src_dest'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1613:in `fu_each_src_dest0'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1595:in `fu_each_src_dest'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:432:in `cp'
        from test.rb:4:in `<main>'
```

The expected result is copy to fooコピー is success same like copy to foo_copy.




-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-dev:51022] [Ruby master Bug#17626] FileUtils.cp may cause utime_failed
  2021-02-13 11:48 [ruby-dev:51020] [Ruby master Bug#17626] FileUtils.cp may cause utime_failed agate.pris
  2021-02-13 13:25 ` [ruby-dev:51021] " xtkoba+ruby
@ 2021-02-14  2:29 ` xtkoba+ruby
  2021-02-14 12:07 ` [ruby-dev:51023] " agate.pris
  2021-02-16  4:17 ` [ruby-dev:51024] " naruse
  3 siblings, 0 replies; 5+ messages in thread
From: xtkoba+ruby @ 2021-02-14  2:29 UTC (permalink / raw)
  To: ruby-dev

Issue #17626 has been updated by xtkoba (Tee KOBAYASHI).

File ruby-w32_utimensat.patch added

I have found a solution to this issue. See the attached patch.

BTW I didn't know that special functions must be used to handle non-ASCII filenames with MinGW.

----------------------------------------
Bug #17626: FileUtils.cp may cause utime_failed
https://bugs.ruby-lang.org/issues/17626#change-90374

* Author: agate-pris (agate pris)
* Status: Open
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x64-mingw32]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN, 3.0: UNKNOWN
----------------------------------------
FileUtils.cp will cause utime_failed if the file name contains Japanese characters and preserve is true.

This will probably only happen on Windows. It occures on Windows 10 version 2004 build 21301.1010.

``` ruby
require 'fileutils'

FileUtils.cp('foo', 'foo_copy', preserve: true)
FileUtils.cp('foo', 'fooコピー', preserve: true)
```

``` sh
$ ruby test.rb
C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1424:in `utime': No such file or directory @ utime_failed - fooコピー (Errno::ENOENT)
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1424:in `copy_metadata'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:515:in `copy_file'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:433:in `block in cp'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1597:in `block in fu_each_src_dest'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1613:in `fu_each_src_dest0'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1595:in `fu_each_src_dest'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:432:in `cp'
        from test.rb:4:in `<main>'
```

The expected result is copy to fooコピー is success same like copy to foo_copy.


---Files--------------------------------
ruby-w32_utimensat.patch (326 Bytes)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-dev:51023] [Ruby master Bug#17626] FileUtils.cp may cause utime_failed
  2021-02-13 11:48 [ruby-dev:51020] [Ruby master Bug#17626] FileUtils.cp may cause utime_failed agate.pris
  2021-02-13 13:25 ` [ruby-dev:51021] " xtkoba+ruby
  2021-02-14  2:29 ` [ruby-dev:51022] " xtkoba+ruby
@ 2021-02-14 12:07 ` agate.pris
  2021-02-16  4:17 ` [ruby-dev:51024] " naruse
  3 siblings, 0 replies; 5+ messages in thread
From: agate.pris @ 2021-02-14 12:07 UTC (permalink / raw)
  To: ruby-dev

Issue #17626 has been updated by agate-pris (agate pris).


Thank you very match!

----------------------------------------
Bug #17626: FileUtils.cp may cause utime_failed
https://bugs.ruby-lang.org/issues/17626#change-90381

* Author: agate-pris (agate pris)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x64-mingw32]
* Backport: 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONTNEED, 3.0: REQUIRED
----------------------------------------
FileUtils.cp will cause utime_failed if the file name contains Japanese characters and preserve is true.

This will probably only happen on Windows. It occures on Windows 10 version 2004 build 21301.1010.

``` ruby
require 'fileutils'

FileUtils.cp('foo', 'foo_copy', preserve: true)
FileUtils.cp('foo', 'fooコピー', preserve: true)
```

``` sh
$ ruby test.rb
C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1424:in `utime': No such file or directory @ utime_failed - fooコピー (Errno::ENOENT)
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1424:in `copy_metadata'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:515:in `copy_file'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:433:in `block in cp'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1597:in `block in fu_each_src_dest'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1613:in `fu_each_src_dest0'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1595:in `fu_each_src_dest'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:432:in `cp'
        from test.rb:4:in `<main>'
```

The expected result is copy to fooコピー is success same like copy to foo_copy.


---Files--------------------------------
ruby-w32_utimensat.patch (326 Bytes)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [ruby-dev:51024] [Ruby master Bug#17626] FileUtils.cp may cause utime_failed
  2021-02-13 11:48 [ruby-dev:51020] [Ruby master Bug#17626] FileUtils.cp may cause utime_failed agate.pris
                   ` (2 preceding siblings ...)
  2021-02-14 12:07 ` [ruby-dev:51023] " agate.pris
@ 2021-02-16  4:17 ` naruse
  3 siblings, 0 replies; 5+ messages in thread
From: naruse @ 2021-02-16  4:17 UTC (permalink / raw)
  To: ruby-dev

Issue #17626 has been updated by naruse (Yui NARUSE).

Backport changed from 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONTNEED, 3.0: REQUIRED to 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONTNEED, 3.0: DONE

ruby_3_0 551f1236a43ad014522d120dea1f136052879c0a merged revision(s) a681c484a3c5b9235c84bc5c253b4406e498e8cf.

----------------------------------------
Bug #17626: FileUtils.cp may cause utime_failed
https://bugs.ruby-lang.org/issues/17626#change-90411

* Author: agate-pris (agate pris)
* Status: Closed
* Priority: Normal
* ruby -v: ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x64-mingw32]
* Backport: 2.5: DONTNEED, 2.6: DONTNEED, 2.7: DONTNEED, 3.0: DONE
----------------------------------------
FileUtils.cp will cause utime_failed if the file name contains Japanese characters and preserve is true.

This will probably only happen on Windows. It occures on Windows 10 version 2004 build 21301.1010.

``` ruby
require 'fileutils'

FileUtils.cp('foo', 'foo_copy', preserve: true)
FileUtils.cp('foo', 'fooコピー', preserve: true)
```

``` sh
$ ruby test.rb
C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1424:in `utime': No such file or directory @ utime_failed - fooコピー (Errno::ENOENT)
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1424:in `copy_metadata'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:515:in `copy_file'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:433:in `block in cp'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1597:in `block in fu_each_src_dest'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1613:in `fu_each_src_dest0'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:1595:in `fu_each_src_dest'
        from C:/tools/ruby30/lib/ruby/3.0.0/fileutils.rb:432:in `cp'
        from test.rb:4:in `<main>'
```

The expected result is copy to fooコピー is success same like copy to foo_copy.


---Files--------------------------------
ruby-w32_utimensat.patch (326 Bytes)


-- 
https://bugs.ruby-lang.org/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-02-16  4:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-13 11:48 [ruby-dev:51020] [Ruby master Bug#17626] FileUtils.cp may cause utime_failed agate.pris
2021-02-13 13:25 ` [ruby-dev:51021] " xtkoba+ruby
2021-02-14  2:29 ` [ruby-dev:51022] " xtkoba+ruby
2021-02-14 12:07 ` [ruby-dev:51023] " agate.pris
2021-02-16  4:17 ` [ruby-dev:51024] " naruse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).