GnuCash
Contact   Instructions
Bug 797630 - Check for missing dependencies of 'Get Quotes' to avoid Gnucash crash
Summary: Check for missing dependencies of 'Get Quotes' to avoid Gnucash crash
Status: RESOLVED FIXED
Alias: None
Product: GnuCash
Classification: Unclassified
Component: Currency and Commodity (show other bugs)
Version: git-maint
Hardware: PC Linux
: Normal enhancement
Target Milestone: ---
Assignee: core
QA Contact: core
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-02-26 16:36 EST by Ferran
Modified: 2021-03-14 13:50 EDT (History)
4 users (show)

See Also:


Attachments

Description Ferran 2020-02-26 16:36:19 EST
Hi,

Whenever I click on the 'Get Quotes' button on the Tools > Price Database menu Gnucash crashes with the following error:

> Backtrace:
>            1 (apply-smob/1 #<catch-closure 7f37ec0bf320>)
> In price-quotes.scm:
>    417:57  0 (gnc:book-add-quotes #<swig-pointer GtkWindow * 559e2d…> …)
> 
> price-quotes.scm:417:57: In procedure gnc:book-add-quotes:
> In procedure car: Wrong type argument in position 1 (expecting pair): ()

I've tried compiling Gnucash against Guile 2.0, but I get a similar error:

> Backtrace:
> In ice-9/boot-9.scm:
>  160: 2 [catch #t #<catch-closure 7f3339d4d500> ...]
> In unknown file:
>    ?: 1 [apply-smob/1 #<catch-closure 7f3339d4d500>]
> In price-quotes.scm:
>  417: 0 [gnc:book-add-quotes # #]
> 
> price-quotes.scm:417:57: In procedure gnc:book-add-quotes:
> price-quotes.scm:417:57: In procedure car: Wrong type argument in position 1 (expecting pair): ()

I've also checked if the problem was in the Finance::Quote Perl module, but I've tested it using 'gncfq-dump' and it seems to work properly (actually I couldn't get results from European stocks, but I believe this is a different problem):

> $ ALPHAVANTAGE_API_KEY=XXXXXXXXXXXXX gnc-fq-dump usa aapl
> Finance::Quote fields Gnucash uses:
>     symbol: aapl                 <=== required
>       date: 02/26/2020           <=== recommended
>   currency: USD                  <=== required
>       last: 292.6500             <=\       
>        nav:                      <=== one of these
>      price:                      <=/        
>   timezone:                      <=== optional

I've tried debugging price-quotes.scm but I'm having a hard time, since my knowledge of Guile/Scheme is very limited and I don't know how to make the display function to print the messages when libguile is being called through Gnucash.

> Software versions:
> Gnucash: git-maint
> Finance::Quote: 1.49
> Guile: 2.2.6/2.0.14
> OS: ArchLinux

I also include a trace file, but a quick look didn't reveal anything really interesting.
If anyone shows me how I can provide more useful information I'll be glad to do it. Any help is greatly appreciated!

Thanks,
Ferran
Comment 1 Ferran 2020-02-26 16:39:12 EST
Tested commit is: feee495f2efb2182f66e6adc3fed2ea96848fc12
Comment 2 Frank H. Ellenberger 2020-02-26 17:07:43 EST
What is the output of:
$ALPHAVANTAGE_API_KEY=XXXXXXXXXXXXX echo '(usa "aapl")' | gnc-fq-helper

Don't forget to adjust the §ALPHAVANTAGE_API_KEY.
Comment 3 Ferran 2020-02-26 17:44:51 EST
Hi Frank, thanks for your help.

The output of the gnc-fq-helper command is the following:

> (("aapl" (symbol . "aapl") (gnc:time-no-zone . "2020-02-26 12:00:00") (last . #e292.65) (currency . "USD")))
Comment 4 Ferran 2020-02-26 17:50:52 EST
In order to run the previous command I had to install the Perl Date::Manip module, since I was getting the following error:

> Can't locate Date/Manip.pm in @INC (you may need to install the Date::Manip module) (@INC contains: /usr/lib/perl5/5.30/site_perl /usr/share/perl5/site_perl /usr/lib/perl5/5.30/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5/5.30/core_perl /usr/share/perl5/core_perl) at bin/gnc-fq-helper line 29.
> BEGIN failed--compilation aborted at bin/gnc-fq-helper line 29.

After installing the package I checked whether the problem persisted, and it did. However, after restarting I've noticed Gnucash no longer crashes, so this was the cause.

Thanks a lot for your help and sorry for the noise!

Ferran
Comment 5 Ferran 2020-02-26 17:56:04 EST
For the record, and in order to help diagnose this better in the future, we could consider extending the code in price-quotes.scm that checks for missing Perl libraries:

>      ((memq 'missing-lib fq-results)                                            
>       (set! keep-going? #f)                                                     
>       (show-error (N_ "You are missing some needed Perl libraries.              
> Run 'gnc-fq-update' as root to install them.")))
Comment 6 Frank H. Ellenberger 2020-02-26 18:27:52 EST
Chris, your opinion on comment 5?
Comment 7 John Ralls 2021-03-14 13:50:52 EDT
It was a perl problem, not a scheme one: There was a use Date::Manip at the top of the gnc-fq-helper that caused a compilation failure before it got to the library check.

Now fixed.

Note You need to log in before you can comment on or make changes to this bug.