This project is archived and is in readonly mode.
Gem tasks fail when cache_classes=true
-
Matt Jones
Don't use "require 'fastercsv'" in your model - config.gem will do it for you if the gem is available.
-
dstrelau
- Tag changed from 2.2.2, bug, cache_classes, initializer, load_application_classes, railties to bug, cache_classes, edge, gems, initializer, load_application_classes, patch, railties, rake
Actually, this is still a problem, even when not using require in the model. Initializer#load_application_classes runs, even when executing a gems task, which means that if the gem isn't installed, you end up with errors. Note this only happens in production or when
config.cache_classes = true.Here is how you can replicate: 1) Uninstall 'thoughtbot-paperclip' if you have it installed 2) New rails project, with vendored rails 3)
config.gem 'thoughtbot-paperclip', :lib => 'paperclip', :source => 'http://gems.github.com'4)script/generate model foo5)class Foo < AR; has_attached_file :image; end6) RAILS_ENV=production rake gemsPatch against master attached, which just doesn't loaded classes if $rails_gem_installer is set:
def load_application_classes if configuration.cache_classes && !$rails_gem_installerPS: I'd love to see this backported into 2.2 as well. :)
-
dstrelau
- Tag changed from bug, cache_classes, edge, gems, initializer, load_application_classes, patch, railties, rake to bug, gems, initializer, patch, railties, rake, tiny
I'm going to bump this, in the hopes that someone might take a look and care, seeing as this bug essentially makes rake gems:install useless for satisfying gem dependencies on a production server.
-
Matt Jones
Take a look at #1750 - I've attached a patch that basically bails out of the initializer if rake gems tasks are being run and gems are missing. This should stop anything like this from happening.
Also see #802, which has probably handled this case already by turning off eager loading in all rake tasks.
