Rails::GemDependency#load prevents missing gems from aborting
application initialization:
fxn@feynman:~/tmp/test_gem$ script/runner 'p 1'
These gems that this application depends on are missing:
- foo
Run "rake gems:install" to install them.
1
Which is the rationale? Why would you want the initialization to go on
in spite of missing gems?
It is not clear to me that the rationale is explained there, but at
least I see there are people that have a notion of "optional
dependency" in which this behaviour might make sense for them.
I am for sure +1 on failing hard and handling your occasional optional
library with Ruby code anyway.
This was discussed in a recent thread. Rubygems already provides a
way to flag development gems. Aside from that, any determiniation of
"optional" is developer-, platform- or environment- specific, and is
best handled with custom code in the environment file(s). In any of
these cases, you would need some custom code anyway to determine
whether the non-development "optional" dependency is actually required
or not (inclusion in a specific environment file rather than
environment.rb, platform check, env var check, etc). So, if you need
custom code anyway, just write your own conditional to not even
execute the optional config.gem call. No need for a separate method.