10

I've just upgraded a project to Ruby 1.9.2 and the following line crashes the app with 'undefined method `copy' for File:Class'

File.copy(animage.image.path(:export), destfile)

I have the following libraries loaded in this module

require 'zip/zipfilesystem'
require 'iconv'
require 'net/ftp'
require 'fileutils'
creativetechnologist
  • 1,452
  • 13
  • 29

2 Answers2

13

It should actually be FileUtils.copy or FileUtils.cp. I wonder how your old project worked with just File.copy, as File doesn't have that method.

refer here: http://santoro.tk/mirror/ruby-core/classes/FileUtils.html#M004325

corroded
  • 21,406
  • 19
  • 83
  • 132
3

You were probably using ftools in 1.8:

ftools adds several (class, not instance) methods to the File class, for copying, moving, deleting, installing, and comparing files, as well as creating a directory path. See the File class for details.

ftools was replaced by fileutils in 1.9, about the 6th element in this list of standard library changes in 1.9 from Dave Thomas

klochner
  • 8,077
  • 1
  • 33
  • 45