Reputation: 535
Looking at the Fileutils.cp_r
documentation, it seems to be using cp -r
in a shell. This command will ignore subdirectories that are empty (at least on my OS X 10.9 machine).
Can anyone suggest a solution that would allow me to include the empty subdirectories?
EDIT: cp -r
in my shell does in fact copy the empty subdirectories, so now I am even more confused...
Upvotes: 1
Views: 158
Reputation: 35914
Wow - So I just ran into this issue while developing a gem. Theres two important things to note:
A gemspec often builds from the available files in git:
Gem::Specification.new do |spec|
spec.files = `git ls-files -z`.split("\x0")
end
Git however, will ignore empty directories from version control.
I was able to work around the issue by adding a .keep
file to ALL empty directories, including their nested empty directories, and the issue was resolved. Which could explain the shell vs ruby scenario in your example.
More information on keep files here: Random 'concerns' folders and '.keep' files
Upvotes: 0
Reputation: 535
I was writing a file within the Homebrew package manager, and it turns out that their build environment deletes empty directories at the end.
Upvotes: 0
Reputation: 2901
Strange. It should copy even the empty directories. I checked on Linux and OSX, here you got the session from OSX:
% mkdir empty
% ruby -e "require 'fileutils'; FileUtils.cp_r 'empty', 'double'"
% ls -ld double
drwxr-xr-x 2 grych staff 68 Jul 31 17:22 double
Upvotes: 1