DuckPAN/DDG: DuckPAN won't die when a module fails to load. #78
Conversation
It's been a perennial problem for DuckPAN users to install all of the dependencies of each IA in the repo before they can even test anything. This patch prevents DuckPAN from exiting when it fails to load an IA. It goes on running, but it warns the user that some IAs didn't load (along with the errors that caused it).
I'm cool with this as per our discussion yesterday. I'd like @moollaza to sign off. Also, from what I can tell, if a module requires more than one unmet dependency the user will have to keep reloading? |
@nilnilnil That is the case--I don't know how to get all the missing dependencies at the moment. I'll make an issue for that. |
an easy way to fix that is to just do |
I was going to recommend something similar to what @nilnilnil has there. If the class fails to load, the error might as well list out all the dependencies of the class (I think it should be a relatively small list?) and then that way they can quickly install all the deps. Maybe the error message should also let them know they can install all deps by running Also @jagtalon please fix the indentation (DuckPAN code uses tabs). |
sub print_failed_modules { | ||
my %failed_to_load = %{shift @_}; | ||
|
||
print "\nSome instant answers failed to load:\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about less fail-oriented: "These instant answers were not loaded"
Looks good |
Alternatively, for modules failing the dependency check at all, you could modify the output of the error message to be something like: Module $spice has unmet dependencies, if you plan to work on them, run |
So I just added some online documentation if they need any help: duckduckgo/duckduckgo-documentation#81 |
@moollaza Should be ready. :) Sorry for the mess--shouldn't have converted everything to spaces |
@jagtalon I preferred the previous approach because the message was way more helpful. At the very least it gave the name of a dependency that I could quickly install. Even if I follow the link it just tells me how that I need to use I think the error message should be similar to how you first had it and it should tell you to check the file for other dependencies. We should still suggest you read that article though if you need more info on installing Perl deps. Something like this seems good: The following instant answers were not loaded:
{
DDG::Goodie::ChineseZodiac - "Missing dependencies! Please install <module> and any other required dependencies to use this instant answer. Check lib/DDG/ChineseZodiac.pm to see what other dependencies are required."
...
}
To learn more about installing Perl dependencies, please read http://duck.co/duckduckhack....
Note: If you are not working on these Instant Answers you can ignore these messages. |
…ing-error Conflicts: lib/App/DuckPAN/DDG.pm
@moollaza Added the change to the message--that's clearer. I didn't add the |
LGTM 👍 |
DuckPAN/DDG: DuckPAN won't die when a module fails to load.
YES! |
FWIW I think the language here, "Note:.. " is too passive. |
It's been a perennial problem for DuckPAN users to install all of the dependencies of each IA in the repo before they can even test anything. This patch prevents DuckPAN from exiting when it fails to load an IA. It goes on running, but it warns the user that some IAs didn't load (along with the errors that caused it). This is especially useful if the dependency is not only a Perl module (which is generally easy to install), but external libraries that may have different installation methods depending on the system (I'm looking at you GNU MPFR which needs
sudo apt-get install libmpfr-dev
on Ubuntu orbrew install mpfr
on OS X).Here it is in action (ChineseZodiac missing a module):
Here it is displaying some other error:
CC @moollaza @nilnilnil