Search code examples
ruby-1.9.2

undefined method `copy' for File:Class


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'

Solution

  • 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