SA Bugzilla – Bug 3799
sa-learn with --dbpath tries to open ~/.spamassassin/bayes* first.
Last modified: 2006-09-09 19:06:38 UTC
When spamassassin learns into a bayes database specified using --dbpath, it first appears to try to open ~/.spamassassin/bayes* for the current user regardless, which may generate warnings & errors which it then appears to ignore. e.g.: % sa-learn --dump=magic --dbpath /etc/mail/virtual/domain/localpart/bayes bayes: bayes db version 2 is not able to be used, aborting! at /usr/local/share/perl/5.6.1/Mail/SpamAssassin/BayesStore/DBM.pm line 160. 0.000 0 3 0 non-token data: bayes db version 0.000 0 4593 0 non-token data: nspam 0.000 0 6334 0 non-token data: nham ... the error is obviously inconsistent - and results from trying to open obsolete a bayes db in ~/.spamassassin/bayes*. The workaround is simply to remove the bayes db from the ~/.spamassassin folder. If --dbpath is set, presumably SA should not autocreate ~/.spamassassin paths, either. The problem can be diagnosed by running sa-learn in -D mode and seeing what db it complained about trying to open. The same problem appears to occur when SA autolearns ham or spam in spamd or presumably normal spamassassin.
I'm not sure if this is really 3.0.1 or 3.1.0, but the scoop is this, in sa-learn, dbpath kluges the configured bayes_path via: $spamtest = new Mail::SpamAssassin( [...] $spamtest->init(1); [...] $spamtest->finish_learner(); $spamtest->{conf}->{bayes_path} = $bayes_override_path; so the init() tries to read the actual configured bayes db and get the learner bit setup, then we change the path and things are good. However, the init() call throws the "version 2" warning (the person's actual bayes db), and then the path overrides and the dump can properly read the other version 3 db. so I'm not sure how to go about fixing this, but we should look into it. perhaps either pass in an option to init() to not init bayes or figure out something cleaner. :)
the more I think about it, the more I decide there's not an easy solution to this, so it's not really 3.0.1 material. pushing to 3.1.0 queue since we can do larger-scale changes there.
punting to 3.2.0, no patch and not a severe problem, unfortunately
Sending lib/Mail/SpamAssassin.pm Sending sa-learn.raw Transmitting file data .. Committed revision 441887. :)