Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NameError: uninitialized constant FileUtils

Tags:

ruby

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.

like image 540
Sam Johnson Avatar asked Dec 24 '22 12:12

Sam Johnson


1 Answers

FileUtils must be explicitly required:

require 'fileutils'
FileUtils.cp('image.png', '/folder/image.png')
like image 115
Aleksei Matiushkin Avatar answered Feb 11 '23 02:02

Aleksei Matiushkin