Can't run rake tasks in production mode
istrasci opened this issue · comments
On my production machine, if I have the gem factory_bot_rails
inside the development & test groups
group :development, :test do
gem 'factory_bot_rails'
...
end
I can't run any rake tasks. Even something as simple as RAILS_ENV=production bundle exe rake -T
. I get the error:
rake aborted!
LoadError: cannot load such file -- factory_bot
However, if I move the gem line out of the group into the "general" area of the Gemfile, it works fine.
I don't understand this at all. None of my rake tasks (let alone rake -T
) even call FactoryBot in any way . So why would the production Rails environment be looking for it at all?
It looks like you are probably requiring factory_bot
or factory_bot_rails
in a file that is getting loaded in your production environment. Try searching your project for require 'factory_bot_rails'
.
I'm going to close this for now. Feel free to reopen if this is still a problem. Thanks!
Sorry, I should have closed it myself. It was another gem that was incorrectly loading factory_bot_rails
into the production environment. So my issue is resolved.
I'm glad you were able to sort it out!