In irb, I do this
class Text
include FileUtils
end
I get: NameError: uninitialized constant Test::FileUtils
If I just do: include FileUtils (i.e. now class) everthing works.
What gives?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need to make sure Ruby knows about the FileUtils module. That module isn’t loaded by default:
Don’t worry too much about the error
NameError: uninitialized constant Text::FileUtils– when you try to include a constant that Ruby doesn’t know about, it looks in a few places. In your case, first it will look forText::FileUtilsand then it will look for::FileUtilsin the root namespace. If it can’t find it anywhere (which in your case it couldn’t) then the error message will tell you the first place it looked.