是否可以使用 App::Fatpacker 使用 Log::Log4perl 来打包脚本?

Is it possible to fatpack script using Log::Log4perl using App::Fatpacker?

我尝试使用 App::Fatpacker 模块中的 fatpack 实用程序(在 CentOS 6.6 64 位 运行 Perl 5.20 上)对我的 Perl 脚本进行 fatpack。我的脚本使用 Log::Log4perl 模块进行日志记录。 fatpack 实用程序抱怨日志记录模块:

fatpack trace collect_genomes_to_database.pl
collect_genomes_to_database.pl syntax OK
fatpack packlists-for `cat fatpacker.trace` >packlists
Can't locate object method "new" via package "Log::Log4perl::Appender" at ~/perl5/lib/perl5/Log/Log4perl/Logger.pm line 33.
Compilation failed in require at ~/perl5/lib/perl5/Log/Log4perl/Config.pm line 8.
BEGIN failed--compilation aborted at ~/perl5/lib/perl5/Log/Log4perl/Config.pm line 8.
Compilation failed in require at ~/perl5/lib/perl5/Log/Log4perl/Appender.pm line 9.
BEGIN failed--compilation aborted at ~/perl5/lib/perl5/Log/Log4perl/Appender.pm line 9.
Compilation failed in require at ~/perl5/lib/perl5/App/FatPacker.pm line 149.
BEGIN failed--compilation aborted at ~/perl5/bin/fatpack line 3.

有人成功打包了包含 Log::Log4perl 的脚本还是不可行?

你能推荐一些其他制作自包含脚本的方法吗?

found a bug in Log4perl.

解决该问题的一种方法是在其余部分之前显式加载 Log4perl。

PERL5OPT='-mLog::Log4perl' fatpack ...

这应该足以解决问题,使事情正常进行。

mstirc.perl.org#toolchain

致敬

docs of App::FatPacker 表示最好通过 irc.perl.org 上的 #toolchain 提供支持。我冒昧地在那里分享了这个问题。

以下是删除无关内容的对话记录。

[16:02:15] <simbabque> mst: interesting question on fatpacker
[16:15:47] <mst> simbabque: not really, the user didn't use their brain and Mithaldu already solved the problem :)
[16:15:47] <Mithaldu> \o/
[16:16:08] <Mithaldu> main problem: user is using an old perl that doesn't tell them to load the module
[16:16:50] <mst> hm, actually, that appears to be the packlists-for command
[16:16:51] <mst> simbabque: wait
[16:16:53] <mst> fuck me running
[16:17:14] <mst> this may be an l4p bug
[16:17:31] <mst> simbabque: ooooh
[16:18:02] <mst> I think
[16:18:24] <mst> Log::Log4perl::Appender is loading ::Config which is loading ::Logger ... which is then trying to ->new on ::Appender before the method's been defined yet
[16:18:49] <mst> hence why packlists-for is blowing up trying to require modules
[16:19:29] <Mithaldu> that sounds various kinds of un fun
[16:21:00] <mst> or he's missed a chunk of error
[16:21:23] <simbabque> that he's missing something sounds likely
[16:21:28] <mst> ah, no, it is doing a require, I am right, and L4p is fucked
[16:21:32] <mst> 149 is 'require $t;'
[16:21:42] <mst> it's a circular require problem in l4p
[16:22:57] <Mithaldu> so he's gonna have to %INC munge?
[16:24:25] <mst> or somebody should hit MSCHILLI with a stick and get it fixed
[16:27:13] <mst> BINGO
[16:27:17] <mst> perl -e 'use Log::Log4perl::Appender;'
[16:27:19] <mst> BOOM
[16:30:15] <mst> https://github.com/mschilli/log4perl/issues/59
[16:30:16] <dipsy> [ Circular require causes explosion · Issue #59 · mschilli/log4perl · GitHub ]
[16:30:22] <mst> can somebody shove that onto SO please
[16:30:35] <Mithaldu> sure
[16:33:44] <kentnl> I imagined you could work around that by avoiding the problem module in packlists-for and copying it manually, after the "Tree" stage. But I haven't done a lot here.
[16:34:11] <mst> PERL5OPT='-mLog::Log4perl' fatpack ...
[16:34:13] -*- ether sees riche has already left :/
[16:34:14] <mst> would probably work
[16:34:26] <mst> yep

正如 Kent Fredric 已经发布的那样,解决方法是

$ PERL5OPT='-mLog::Log4perl' fatpack collect_genomes_to_database.pl

...不过他发帖速度更快


这就是工作中的 Perl 社区。 :)