IP: 38.107.179.228
  • Backup and Disaster Recovery
  • Monitoring
  • Is working with your business vendors always pleasant?
  • Do you know which cloud services are right for you?

ActiveSupport error: uninitialized constant FileUtils

Written by Adrian Goins on Aug 16, 2010 in Ruby

In some situations when using ActiveRecord, you might encounter an error like the following:

/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:443:in `load_missing_constant': uninitialized constant FileUtils (NameError) from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:80:in `const_missing' from /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active_support/dependencies.rb:92:in `const_missing' from /root/bin/aws_postgres_s3_utility.rb:47:in `archive_file' from /root/bin/aws_postgres_s3_utility.rb:76

The problem is caused by the BufferedLogger not requiring 'fileutils' before calling a method within the FileUtils module.  While the fix for this should be within active_support, you can solve it by requiring the library within your own script:

require 'fileutils'

This will load the FileUtils module, so that when active_support calls it, it will exist.