rubinius/rubinius — Issue #1458: FileUtils.cp in 1.9 mode doesn’t work
Author: Quintus
Created: 2011-12-19 21:26:13+00:00
State: open

Hi there,

While hunting down error messages caused by RubyGems in 1.9 mode I found that the FileUtils.cp method doesn’t do what it is supposed to do. Here’s a simple example:

$ ls -hl
-rw-r--r-- 1 quintus quintus 96K 19. Dez 20:46 coderay-1.0.4.gem

Note the file size. 96K. Unpacking this gem via `gem unpack` works fine with MRI RubyGems.

Then, I copy this file:

$ rbx -rfileutils
irb(main):001:0> FileUtils.mkdir "foo"
=> ["foo"]
irb(main):002:0> FileUtils.cp("coderay-1.0.4.gem", "foo")
=> nil
irb(main):003:0> RUBY_DESCRIPTION
=> "rubinius 2.0.0dev (1.9.3 30c0c564 yyyy-mm-dd JI) [x86_64-unknown-linux-gnu]"
irb(main):004:0> exit

Note the new file size:

$ ls -hl foo
-rw-r--r-- 1 quintus quintus 16K 19. Dez 22:18 coderay-1.0.4.gem

Obviously FileUtils has lost some bytes while copying. Of course, trying to unpack this gem fails:

$ gem unpack coderay-1.0.4.gem
ERROR: While executing gem ... (Gem::Package::FormatError)
no metadata found in coderay-1.0.4.gem

The same operations in 1.8 mode work correctly.

OS: Arch Linux 64bits
rbx -v: `rubinius 2.0.0dev (1.9.3 30c0c564 yyyy-mm-dd JI) [x86_64-unknown-linux-gnu]`

The file I copied is the normal CodeRay gem, get it by `gem fetch coderay` if you want to play around with it. The problem however arises with other files as well, just not for simple text files as it seems.

Valete,
Marvin