简体   繁体   中英

NameError: uninitialized constant FileUtils

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.

FileUtils must be explicitly require d:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM