NameError: uninitialized constant FileUtils

Viewed 3538

I tried to copy a file from my desktop to another folder with this code:

 FileUtils.cp('image.png', '/folder/image.png')

I got this error:

NameError: uninitialized constant FileUtils
Did you mean? FileTest

I am trying to work out why I got the error.

1 Answers

FileUtils must be explicitly required:

require 'fileutils'
FileUtils.cp('image.png', '/folder/image.png')
Related