Skip Menu |

This queue is for tickets about the Module-ScanDeps CPAN distribution.

Report information
The Basics
Id: 72082
Status: resolved
Priority: 0/
Queue: Module-ScanDeps

People
Owner: RSCHUPP [...] cpan.org
Requestors: mdengfeng [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: $FindBin::Bin issue on Moudel::ScanDeps 1.04
Date: Tue, 1 Nov 2011 13:21:36 +0800
To: bug-Module-ScanDeps [...] rt.cpan.org
From: DengFeng Mao <mdengfeng [...] gmail.com>
Hi, Experts I got some issue on Module::ScanDeps 1.04. But not on Module::ScanDeps 1.02. There is a simple test.pl file. You can get the its content in below 'cat' command. On the host hostA, the version of Module::ScanDeps is 1.02. The 'scandeps.pl' can output the correct result. For the same test.pl file. On the hostBm the version of Module::ScanDeps is 1.04, The 'scandeps.pl' command get some issue. It seems the '$FindBin::Bin' was redirected to '/tmp' instead of the correct folder. So it caused some modules can't be used correctly. Thanks in advance. Dengfeng ======================================================= hostA ======================================================= hostA [216]: ls lib test.pl hostA [217]: cat test.pl use FindBin; use lib "$FindBin::Bin/lib"; use MYMODULE; print "Hello World!\n" hostA [218]: perl -V Summary of my perl5 (revision 5 version 12 subversion 3) configuration: Platform: osname=linux, osvers=2.6.18-164.el5, archname=x86_64-linux-thread-multi uname='linux hostA 2.6.18-164.el5 #1 smp tue aug 18 15:51:48 edt 2009 x86_64 x86_64 x86_64 gnulinux ' config_args='-Dcc=gcc -Dusethreads -Duse64bitall -Dprefix=/home/dfmao/perl-5.12.3/linuxR_x86 -de' hint=recommended, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' ccversion='', gccversion='4.1.2 20080704 (Red Hat 4.1.2-46)', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='gcc', ldflags =' -fstack-protector -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64 /usr/local/lib64 libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc libc=/lib/libc-2.5.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.5' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP USE_64_BIT_ALL USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF USE_REENTRANT_API Built under linux Compiled at Jul 7 2011 10:01:50 @INC: /home/dfmao/perl-5.12.3/linuxR_x86/lib/site_perl/5.12.3/x86_64-linux-thread-multi /home/dfmao/perl-5.12.3/linuxR_x86/lib/site_perl/5.12.3 /home/dfmao/perl-5.12.3/linuxR_x86/lib/5.12.3/x86_64-linux-thread-multi /home/dfmao/perl-5.12.3/linuxR_x86/lib/5.12.3 . hostA [219]: perl -MModule::ScanDeps -e 'print $Module::ScanDeps::VERSION' 1.02 hostA [220]: scandeps.pl -c test.pl 'MYMODULE' => 'undef', 'Archive::Zip::Archive' => '1.30', 'Archive::Zip::DirectoryMember' => '1.30', 'Archive::Zip::FileMember' => '1.30', 'Archive::Zip::Member' => '1.30', 'Archive::Zip::NewFileMember' => '1.30', 'Archive::Zip::StringMember' => '1.30', 'Archive::Zip::ZipFileMember' => '1.30', 'URI::URL' => '5.03', 'Expect' => '1.21', 'HTTP::Request' => '5.827', 'HTTP::Date' => '5.831', 'URI::http' => 'undef', 'LWP::UserAgent' => '5.835', 'LWP::Authen::Digest' => 'undef', 'LWP::Authen::Ntlm' => '5.835', 'LWP::Protocol::GHTTP' => 'undef', 'LWP::Protocol::cpan' => 'undef', 'LWP::Protocol::data' => 'undef', 'LWP::Protocol::file' => 'undef', 'LWP::Protocol::ftp' => 'undef', 'LWP::Protocol::gopher' => 'undef', 'LWP::Protocol::https' => 'undef', 'LWP::Protocol::https10' => 'undef', 'LWP::Protocol::loopback' => 'undef', 'LWP::Protocol::mailto' => 'undef', 'LWP::Protocol::nntp' => 'undef', 'LWP::Protocol::nogo' => 'undef', 'LWP::Authen::Basic' => 'undef', 'LWP::Protocol::http' => 'undef', 'LWP::Protocol::http10' => 'undef', 'HTML::LinkExtor' => '3.60', 'Archive::Zip' => '1.30', 'Crypt::SSLeay::X509' => 'undef', 'Crypt::SSLeay::CTX' => 'undef', 'IO::Pty' => '1.10', 'IO::Tty' => '1.10', 'HTML::Tagset' => '3.20', 'HTML::Parser' => '3.68', 'URI' => '1.58', 'URI::data' => 'undef', 'URI::_query' => 'undef', 'URI::_punycode' => '0.03', 'URI::_userpass' => 'undef', 'URI::mailto' => 'undef', 'URI::IRI' => 'undef', 'URI::QueryParam' => 'undef', 'URI::Split' => 'undef', 'URI::_foreign' => 'undef', 'URI::_segment' => 'undef', 'URI::file::FAT' => 'undef', 'URI::file::Mac' => 'undef', 'URI::file::OS2' => 'undef', 'URI::file::QNX' => 'undef', 'URI::ftp' => 'undef', 'URI::gopher' => 'undef', 'URI::https' => 'undef', 'URI::ldapi' => 'undef', 'URI::ldaps' => 'undef', 'URI::mms' => 'undef', 'URI::nntp' => 'undef', 'URI::pop' => 'undef', 'URI::rlogin' => 'undef', 'URI::rsync' => 'undef', 'URI::rtspu' => 'undef', 'URI::sips' => 'undef', 'URI::snews' => 'undef', 'URI::ssh' => 'undef', 'URI::telnet' => 'undef', 'URI::tn3270' => 'undef', 'URI::Heuristic' => '4.19', 'URI::_idna' => 'undef', 'URI::file::Unix' => 'undef', 'URI::ldap' => '1.11', 'URI::rtsp' => 'undef', 'URI::_login' => 'undef', 'URI::file::Win32' => 'undef', 'URI::file::Base' => 'undef', 'URI::_ldap' => '1.11', 'URI::news' => 'undef', 'URI::sip' => '0.10', 'URI::_generic' => 'undef', 'URI::_server' => 'undef', 'HTTP::Cookies::Netscape' => '5.832', 'HTTP::Message' => '5.837', 'IO::Tty::Constant' => 'undef', 'HTML::Entities' => '3.68', 'File::Listing' => '5.837', 'HTTP::Negotiate' => '5.835', 'LWP::MediaTypes' => '5.835', 'Net::HTTP' => '5.834', 'HTTP::Status' => '5.817', 'Net::HTTPS' => '5.819', 'Net::SSL' => '2.85', 'HTML::HeadParser' => '3.66', 'HTTP::Config' => '5.835', 'HTTP::Request::Common' => '5.824', 'LWP::ConnCache' => '5.810', 'HTTP::Cookies' => '5.837', 'HTTP::Headers' => '5.835', 'HTTP::Headers::Util' => '5.817', 'LWP::MemberMixin' => 'undef', 'LWP' => '5.837', 'LWP::Protocol' => '5.829', 'HTTP::Response' => '5.836', 'PAR::Dist' => '0.47', 'YAML::Tiny' => '1.50', 'Net::HTTP::Methods' => '5.834', 'Crypt::SSLeay::Conn' => 'undef', 'Crypt::SSLeay::Err' => 'undef', 'Crypt::SSLeay::MainContext' => 'undef', 'Crypt::SSLeay' => '0.58', 'LWP::Simple' => '5.835', 'URI::WithBase' => '2.19', 'URI::file' => '4.20', 'URI::Escape' => '3.30', ================================================== =============================================== hostB =============================================== hostB [210]: ls lib test.pl hostB [211]: cat test.pl use FindBin; use lib "$FindBin::Bin/lib"; use MYMODULE; print "Hello World!\n" hostB [212]: perl -V Summary of my perl5 (revision 5 version 12 subversion 3) configuration: Platform: osname=linux, osvers=2.6.9-34.el, archname=ppc64-linux-thread-multi uname='linux hostB 2.6.9-34.el #1 smp fri feb 24 16:46:57 est 2006 ppc64 ppc64 ppc64 gnulinux ' config_args='-Dcc=gcc -Dusethreads -Dprefix=/home/dfmao/perl-5.12.3/plinuxR -de' hint=recommended, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O1', cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -I/usr/local/include' ccversion='', gccversion='3.4.5 20051201 (Red Hat 3.4.5-2)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='gcc', ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64 libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc libc=/lib/libc-2.3.4.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.3.4' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -O1 -L/usr/local/lib' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF USE_REENTRANT_API Built under linux Compiled at Oct 26 2011 23:07:19 @INC: /home/dfmao/perl-5.12.3/plinuxR/lib/site_perl/5.12.3/ppc64-linux-thread-multi /home/dfmao/perl-5.12.3/plinuxR/lib/site_perl/5.12.3 /home/dfmao/perl-5.12.3/plinuxR/lib/5.12.3/ppc64-linux-thread-multi /home/dfmao/perl-5.12.3/plinuxR/lib/5.12.3 . hostB [215]: perl -MModule::ScanDeps -e 'print $Module::ScanDeps::VERSION' 1.04 hostB [216]: scandeps.pl -c test.pl Can't locate MYMODULE.pm in @INC (@INC contains: /tmp/lib /home/dfmao/perl-5.12.3/plinuxR/lib/site_perl/5.12.3/ppc64-linux-thread-multi /home/dfmao/perl-5.12.3/plinuxR/lib/site_perl/5.12.3 /home/dfmao/perl-5.12.3/plinuxR/lib/5.12.3/ppc64-linux-thread-multi /home/dfmao/perl-5.12.3/plinuxR/lib/5.12.3 .) at test.pl line 5. BEGIN failed--compilation aborted at test.pl line 5. SYSTEM ERROR in compiling test.pl: 512 at /home/dfmao/perl-5.12.3/plinuxR/lib/site_perl/5.12.3/Module/ScanDeps.pm line 1265. -- --------------------------------------------------------- Market is wrong, But I am right!

Message body is not shown because it is too large.

OK, I see what's happening: When you call scandeps.pl with option -c (or -x) it creates a temporary file that contains the text of the file to scan plus some prologue code. This prologue code will be called at the end of compilation (-c) or execution (-x) and just dumps the contents of %INC, $INC etc. scandeps.pl runs an inferior perl on this temporary file and reads back the information. This temporary file used to be created in your working directory, so if your script is also located there, FindBin for your script and for the temp file would come to the same result. In 1.04 I changed it so that the temp file is created in your platform's temp directory. That explains why you see /tmp/lib in @INC in the error message. Can you try the attached patch? It makes FindBin return the correct result by setting $0 to the path of your script. Cheers, Roderich
Subject: findbin.patch
Index: lib/Module/ScanDeps.pm =================================================================== --- lib/Module/ScanDeps.pm (revision 1285) +++ lib/Module/ScanDeps.pm (working copy) @@ -1241,14 +1241,23 @@ my ($feed_fh, $feed_file) = File::Temp::tempfile(); my $dump_file = "$feed_file.out"; + require Data::Dumper; + + # fake $0 (to $file) so that FindBin works as expected + # NOTE: We don't directly assign to $0 as it has magic (that may + # fail, cf. perlvar(1)), instead we alias *0 to a package variable + # holding the correct value. + print $feed_fh "BEGIN { ", + Data::Dumper->Dump([ $file ], [ "Module::ScanDeps::DataFeed::_0" ]), + "*0 = \\\$Module::ScanDeps::DataFeed::_0; }\n"; + print $feed_fh $do_compile ? "INIT {\n" : "END {\n"; # NOTE: When compiling the block will run _after_ all CHECK blocks # (but _before_ the first INIT block) and will terminate the program. # When executing the block will run as the first END block and # the programs continues. - # correctly escape filenames - require Data::Dumper; + # correctly escape strings containing filenames print $feed_fh map { "my $_" } Data::Dumper->Dump( [ $INC{"Module/ScanDeps/DataFeed.pm"}, $dump_file ], [ qw( datafeedpm dump_file ) ]);
Subject: Re: [rt.cpan.org #72082] $FindBin::Bin issue on Moudel::ScanDeps 1.04
Date: Wed, 2 Nov 2011 09:35:51 +0800
To: bug-Module-ScanDeps [...] rt.cpan.org
From: DengFeng Mao <mdengfeng [...] gmail.com>
Yes, the patch works for the FindBin case now. scandeps.pl can output the correct modules. Really appreciate your quick response. Thanks Dengfeng 2011/11/2 Roderich Schupp via RT <bug-Module-ScanDeps@rt.cpan.org> Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=72082 > > > OK, I see what's happening: > > When you call scandeps.pl with option > -c (or -x) it creates a temporary file that contains the text > of the file to scan plus some prologue code. This prologue code > will be called at the end of compilation (-c) or execution (-x) > and just dumps the contents of %INC, $INC etc. scandeps.pl runs > an inferior perl on this temporary file and reads back the information. > > This temporary file used to be created in your working directory, > so if your script is also located there, FindBin for your script > and for the temp file would come to the same result. > > In 1.04 I changed it so that the temp file is created in your > platform's temp directory. That explains why you see /tmp/lib > in @INC in the error message. > > Can you try the attached patch? It makes FindBin return > the correct result by setting $0 to the path of your script. > > Cheers, Roderich > > > >
-- --------------------------------------------------------- Market is wrong, But I am right!
On 2011-11-01 21:36:00, mdengfeng@gmail.com wrote: Show quoted text
> Yes, the patch works for the FindBin case now. scandeps.pl can output the > correct modules.
Thanks for confirming. Fix is contained in 1.05, just uploaded to CPAN. Cheers, Roderich