I have some rake tasks that I only perform locally. However since I refer to the some gem classes in rake tasks, this seems to require that the gem be installed and loaded on the production server. Among other things this increases deploy time and memory usage on the server.
This may or may not have to do with my setting:
config.autoload_paths += Dir["#{config.root}/lib/**/"]
I have a number of lib files and subdirectories.
I guess my options are to
This seems like a pretty common issue and probably has a common way to solve it or avoid it. What am I missing?
Maybe not the most exciting answer but I just moved the require 'dev_gem'
inside the rake task
block for that task.
namespace :elasticbeanstalk do
desc 'Creates a new web & worker environment pair for testing'
task :create do
require 'aws-sdk-elasticbeanstalk'
# Do stuff with beanstalk that we wouldn't from a production env
end
end
This way the library only gets loaded when the rake task is invoked rather than when the rake task is defined.