Undefined subroutine &Getopt::Long::GetOptionsFromArray?

915 views
Skip to first unread message

Victor Hooi

unread,
Aug 7, 2012, 7:39:07 PM8/7/12
to ack-...@googlegroups.com
Hi,

I just pulled ack2 from Git, then compiled it on a OSX host.

I then moved ack-standalone to a Redhat EL 5.3 host, and tried to run it. Perl is version 5.8.8 here:

$ perl --version
This is perl, v5.8.8 built for x86_64-linux-thread-multi
Copyright 1987-2006, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

It gave the error message:

Undefined subroutine &Getopt::Long::GetOptionsFromArray called at /home/<username>/ack-standalone line 3536.

I've pasted the lines around there in case it helps:

3507 sub remove_default_options_if_needed {$
3508     my ( $sources ) = @_;$
3509 $
3510     my $default_index;$
3511 $
3512     foreach my $index ( 0 .. $#$sources ) {$
3513         if ( $sources->[$index] eq 'Defaults' ) {$
3514             $default_index = $index;$
3515             last;$
3516         }$
3517     }$
3518 $
3519     return $sources unless defined $default_index;$
3520 $
3521     my $should_remove = 0;$
3522 $
3523     Getopt::Long::Configure('default'); # start with default options$
3524     Getopt::Long::Configure($
3525         'no_ignore_case',$
3526         'no_auto_abbrev',$
3527         'pass_through',$
3528     );$
3529 $
3530     foreach my $index ( $default_index + 2 .. $#$sources ) {$
3531         next if $index % 2 != 0;$
3532 $
3533         my ( $name, $args ) = @{$sources}[ $index, $index + 1 ];$
3534 $
3535         if(ref($args)) {$
3536             Getopt::Long::GetOptionsFromArray($args,$
3537                 'ignore-ack-defaults' => \$should_remove,$
3538             );$
3539         } else {$
3540             ( undef, $sources->[$index + 1] ) = Getopt::Long::GetOptionsFromString($args,$
3541                 'ignore-ack-defaults' => \$should_remove,$
3542             );$
3543         }$
3544     }$
3545 $
3546     Getopt::Long::Configure('default');$
3547 $

I thought ack standalone was meant to include everything it needed? Or is it using Getopt::Long from my system here? (I'm not too familiar with Perl, to be honest). Any way to package this required module with Ack? Or way around this?

Cheers,
Victor

Andy Lester

unread,
Aug 7, 2012, 9:58:09 PM8/7/12
to ack-...@googlegroups.com

On Aug 7, 2012, at 6:39 PM, Victor Hooi <victo...@gmail.com> wrote:

> I thought ack standalone was meant to include everything it needed? Or is it using Getopt::Long from my system here? (I'm not too familiar with Perl, to be honest). Any way to package this required module with Ack? Or way around this?

ack-standalone contains all the non-core Perl modules. The only non-core Perl module that ack uses is File::Next, and that gets folded into ack-standalone.

What I think the problem is is that you don't have a new enough version of Getopt::Long. ack needs 2.36, and I'm guessing yours is older. Do this to verify:

perldoc -m Getopt::Long | grep '$VERSION'


Currently, the only version check on Getopt::Long is a build-time check in Makefile.PL. We need runtime checks. I'm adding a task for this. https://github.com/petdance/ack2/issues/143

xoa


--
Andy Lester => an...@petdance.com => www.petdance.com => AIM:petdance

Victor Hooi

unread,
Aug 8, 2012, 12:10:04 AM8/8/12
to ack-...@googlegroups.com
Hi,

I just rang that - I have version 2.35 =(:

$ perldoc -m Getopt::Long | grep '$VERSION'
use vars qw($VERSION);
$VERSION        =  2.35;
#use vars qw($VERSION_STRING);
#$VERSION_STRING = "2.35";
($major_version, $minor_version) = $VERSION =~ /^(\d+)\.(\d+)/;
                 ? $Getopt::Long::VERSION_STRING : $VERSION, ";",

Is there any way to package it into the standalone version? Or otherwise get this to work, short of having root rights on the box? (Unlikely...lol).

Cheers,
Victor

Andy Lester

unread,
Aug 8, 2012, 12:14:37 AM8/8/12
to ack-...@googlegroups.com

On Aug 7, 2012, at 11:10 PM, Victor Hooi <victo...@gmail.com> wrote:

> Is there any way to package it into the standalone version? Or otherwise get this to work, short of having root rights on the box? (Unlikely...lol).

I don't have an easy way to do it, no. I definitely don't want to add Getopt::Long to what gets distributed in ack-standalone. The Perl you're running against is a pretty old one. Sorry.

Christopher J. Madsen

unread,
Aug 8, 2012, 3:17:54 PM8/8/12
to ack-...@googlegroups.com
On 8/7/2012 11:10 PM, Victor Hooi wrote:
> Is there any way to package it into the standalone version? Or otherwise
> get this to work, short of having root rights on the box? (Unlikely...lol).

You don't need root access to install modules for your own use. One
solution is to use local::lib:

http://stackoverflow.com/q/2980297/8355
http://search.cpan.org/perldoc?local%3A%3Alib

--
Chris Madsen pe...@cjmweb.net
-------------------- http://www.cjmweb.net --------------------

Andy Lester

unread,
Aug 8, 2012, 3:23:58 PM8/8/12
to ack-...@googlegroups.com

On Aug 8, 2012, at 2:17 PM, Christopher J. Madsen wrote:

You don't need root access to install modules for your own use.  One
solution is to use local::lib:

 http://stackoverflow.com/q/2980297/8355
 http://search.cpan.org/perldoc?local%3A%3Alib

What would he have to do to ack-standalone to make it use the locally installed modules?  Just add a "use local::lib;" at the top?

Christopher J. Madsen

unread,
Aug 8, 2012, 3:31:23 PM8/8/12
to ack-...@googlegroups.com
On 8/8/2012 2:23 PM, Andy Lester wrote:
> On Aug 8, 2012, at 2:17 PM, Christopher J. Madsen wrote:
>> You don't need root access to install modules for your own use. One
>> solution is to use local::lib:
>>
>> http://stackoverflow.com/q/2980297/8355
>> http://search.cpan.org/perldoc?local%3A%3Alib
>
> What would he have to do to ack-standalone to make it use the locally installed modules? Just add a "use local::lib;" at the top?

The normal way of using local::lib is to have it set PERL5LIB so that
Perl uses local::lib-installed modules automatically. You don't need to
make any change to ack-standalone in that case. The Stack Overflow
answer includes the steps to do that both for your current shell session
and for future sessions.

If you don't set PERL5LIB, then adding "use local::lib;" at the top of
ack-standalone would work (assuming you used the default path for your
local::lib directory).

Andy Lester

unread,
Aug 8, 2012, 3:32:57 PM8/8/12
to ack-...@googlegroups.com

On Aug 8, 2012, at 2:31 PM, Christopher J. Madsen wrote:

The normal way of using local::lib is to have it set PERL5LIB so that
Perl uses local::lib-installed modules automatically.  You don't need to
make any change to ack-standalone in that case.  The Stack Overflow
answer includes the steps to do that both for your current shell session
and for future sessions.

If you don't set PERL5LIB, then adding "use local::lib;" at the top of
ack-standalone would work (assuming you used the default path for your
local::lib directory).

Thanks for this. I'm thinking it ought to go in the docs somewhere.

Victor Hooi

unread,
Aug 8, 2012, 7:00:38 PM8/8/12
to ack-...@googlegroups.com
heya,

Cool, that sounds like it might work =).

One thing that complicates things somewhat - the box in question doesn't have direct internet access.

We have other boxes that have internet access, and we can SCP stuff across to that box.

Is there still a way to bootstrap and setup Local::Lib and Getopt::Long?

Cheers,
Victor

Christopher J. Madsen

unread,
Aug 8, 2012, 7:23:39 PM8/8/12
to ack-...@googlegroups.com
On 8/8/2012 6:00 PM, Victor Hooi wrote:
> One thing that complicates things somewhat - the box in question doesn't
> have direct internet access.

> Is there still a way to bootstrap and setup Local::Lib and Getopt::Long?

Of course, it's just more complicated. cpanm and local::lib don't do
anything you can't do manually. If you only want to install one module,
it's probably easier to do it by hand.

Get http://cpan.metacpan.org/authors/id/J/JV/JV/Getopt-Long-2.38.tar.gz

tar xzf Getopt-Long-2.38.tar.gz
cd Getopt-Long-2.38
perl Makefile.PL INSTALL_BASE=/some/dir
make test
make install
export PERL5LIB=/some/dir/lib/perl5

You'll need to set PERL5LIB in your profile to make it persistent.

If you want to install a number of modules, you should look at setting
up a local CPAN mirror: http://stackoverflow.com/q/11224325/8355

Victor Hooi

unread,
Aug 8, 2012, 10:17:40 PM8/8/12
to ack-...@googlegroups.com
heya,

Cool, thanks for the tip. tl:dr version - I managed to install, but ack2 not picking it up - see below:

Hmm, using INSTALL_BASE didn't work, I got:

$ perl Makefile.PL INSTALL_BASE=/home/<username>/perl_modules
Checking if your kit is complete...
Looks good
'INSTALL_BASE' is not a known MakeMaker parameter name.
Writing Makefile for Getopt::Long

However, using PREFIX did work, and it installed correctly:

$ make install
Manifying blib/man3/Getopt::Long.3pm
Installing /home/<username>/perl_modules/lib/perl5/5.8.8/newgetopt.pl
Installing /home/<username>/perl_modules/lib/perl5/5.8.8/Getopt/Long.pm
Installing /home/v<username>/perl_modules/share/man/man3/Getopt::Long.3pm
Writing /home/<username>/perl_modules/lib64/perl5/5.8.8/x86_64-linux-thread-multi/auto/Getopt/Long/.packlist
Appending installation info to /home/<username>/perl_modules/lib64/perl5/5.8.8/x86_64-linux-thread-multi/perllocal.pod

I then exported PERL5LIB:

$ export PERL5LIB=/home/<username>/perl_modules

However, ack2 still doesn't seem to see that.

Undefined subroutine &Getopt::Long::GetOptionsFromArray called at /home/<username>/ack-standalone2 line 3536.

I ran perl -V to double-check - seems to have recognised that new directory:

$ perl -V
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
  Platform:
    osname=linux, osvers=2.6.9-78.0.1.elsmp, archname=x86_64-linux-thread-multi
    uname='linux hs20-bc1-7.build.redhat.com 2.6.9-78.0.1.elsmp #1 smp tue jul 22 18:01:05 edt 2008 x86_64 x86_64 x86_64 gnulinux '
    config_args='-des -Doptimize=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic -Dversion=5.8.8 -Dmyhostname=localhost -Dperladmin=root@localhost -Dcc=gcc -Dcf_by=Red Hat, Inc. -Dinstallprefix=/usr -Dprefix=/usr -Dlibpth=/usr/local/lib64 /lib64 /usr/lib64 -Dprivlib=/usr/lib/perl5/5.8.8 -Dsitelib=/usr/lib/perl5/site_perl/5.8.8 -Dvendorlib=/usr/lib/perl5/vendor_perl/5.8.8 -Darchlib=/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi -Dsitearch=/usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi -Dvendorarch=/usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi -Darchname=x86_64-linux -Dvendorprefix=/usr -Dsiteprefix=/usr -Duseshrplib -Dusethreads -Duseithreads -Duselargefiles -Dd_dosuid -Dd_semctl_semun -Di_db -Ui_ndbm -Di_gdbm -Di_shadow -Di_syslog -Dman3ext=3pm -Duseperlio -Dinstallusrbinperl=n -Ubincompat5005 -Uversiononly -Dpager=/usr/bin/less -isr -Dd_gethostent_r_proto -Ud_endhostent_r_proto -Ud_sethostent_r_proto -Ud_endprotoent_r_proto -Ud_setprotoent_r_proto -Ud_endservent_r_proto -Ud_setservent_r_proto -Dinc_version_list=5.8.7 5.8.6 5.8.5 -Dscriptdir=/usr/bin'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=define use5005threads=undef 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 -Wdeclaration-after-statement -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -I/usr/include/gdbm',
    optimize='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -Wdeclaration-after-statement -I/usr/local/include -I/usr/include/gdbm'
    ccversion='', gccversion='4.1.2 20071124 (Red Hat 4.1.2-41)', 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 =''
    libpth=/usr/local/lib64 /lib64 /usr/lib64
    libs=-lresolv -lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lresolv -lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=, so=so, useshrplib=true, libperl=libperl.so
    gnulibc_version='2.5'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E -Wl,-rpath,/usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi/CORE'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'

Characteristics of this binary (from libperl):
  Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT
                        PERL_MALLOC_WRAP USE_64_BIT_ALL USE_64_BIT_INT
                        USE_ITHREADS USE_LARGE_FILES USE_PERLIO
                        USE_REENTRANT_API
  Built under linux
  Compiled at Sep 24 2008 11:41:17
  %ENV:
    PERL5LIB="/home/<username>/perl_modules"
  @INC:
    /home/<username>/perl_modules
    /usr/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi
    /usr/lib64/perl5/site_perl/5.8.7/x86_64-linux-thread-multi
    /usr/lib64/perl5/site_perl/5.8.6/x86_64-linux-thread-multi
    /usr/lib64/perl5/site_perl/5.8.5/x86_64-linux-thread-multi
    /usr/lib/perl5/site_perl/5.8.8
    /usr/lib/perl5/site_perl/5.8.7
    /usr/lib/perl5/site_perl/5.8.6
    /usr/lib/perl5/site_perl/5.8.5
    /usr/lib/perl5/site_perl
    /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi
    /usr/lib64/perl5/vendor_perl/5.8.7/x86_64-linux-thread-multi
    /usr/lib64/perl5/vendor_perl/5.8.6/x86_64-linux-thread-multi
    /usr/lib64/perl5/vendor_perl/5.8.5/x86_64-linux-thread-multi
    /usr/lib/perl5/vendor_perl/5.8.8
    /usr/lib/perl5/vendor_perl/5.8.7
    /usr/lib/perl5/vendor_perl/5.8.6
    /usr/lib/perl5/vendor_perl/5.8.5
    /usr/lib/perl5/vendor_perl
    /usr/lib64/perl5/5.8.8/x86_64-linux-thread-multi
    /usr/lib/perl5/5.8.8
    .

I thought of specifiying a deeper directory for PERL5LIB:

$ export PERL5LIB=/home/<username>/perl_modules/lib64/perl5/5.8.8/x86_64-linux-thread-multi

I still get the Undefined Subroutine error - any ideas?

Cheers,
Victor

Christopher J. Madsen

unread,
Aug 8, 2012, 10:23:37 PM8/8/12
to ack-...@googlegroups.com
On 8/8/2012 9:17 PM, Victor Hooi wrote:

> Hmm, using INSTALL_BASE didn't work, I got:

I forgot you've got an old MakeMaker, too.

> However, using PREFIX did work, and it installed correctly:

PREFIX works differently. With that, you need to

export
PERL5LIB=/home/<username>/perl_modules/lib64/perl5/5.8.8/x86_64-linux-thread-multi:/home/<username>/perl_modules/lib/perl5/5.8.8

(that should be all 1 long line with no spaces)

Victor Hooi

unread,
Aug 10, 2012, 3:12:44 AM8/10/12
to ack-...@googlegroups.com
heya,

I can verify this all works now =).

Cheers,
Victor
Reply all
Reply to author
Forward
0 new messages