Daniel Rikowski
Daniel Rikowski

Reputation: 72514

Is there any way to make FileUtils work with UTF-8 file names?

I have created this Ruby (1.9.2) code and the last line fails:

File.open("test äöü.txt", "w+").close
File.chmod(0644, "test äöü.txt")
FileUtils.chmod(0644, "test äöü.txt") # FAILS

The message is:

Errno::ENOENT (No such file or directory - C:/.../test ├ñ├Â├╝.txt):

Althoug the FileUtil.chmod calls File.chmod eventually, for some reason it messes with the file name along the way.

Normally I'd just use File instead of FileUtils, but unfortunately I'm using a gem which uses FileUtils and I'm hoping I can avoid changing the gem source.

Does anyone know why this is happening? The source of FileUtils.chmod looks straightforward but I still can't figure out the problem. Is there any way to monkey-patch FileUtils to make it work?

Thanks.

Upvotes: 1

Views: 552

Answers (1)

Marc-André Lafortune
Marc-André Lafortune

Reputation: 79562

It appears to be a Windows only problem, related to issue 1685.

Hopefully someone with a good understanding of encoding issues & windows can enlighten you as to what can be done until it is resolved.

Upvotes: 1

Related Questions