Hi,
the CPAN::Shell perl module is installed but when called in a script an
error message advises installing it.
Clues please?
Macintosh-2:~ root# cat ./update.no.version.sh
#!/sw/bin/perl
# install my favorite programs if necessary:
for $mod (qw(Net::FTP MD5 Data::Dumper)){
my $obj = CPAN::Shell->expand('Module',$mod);
$obj->install;
}
# list all modules on my disk that have no VERSION number
for $mod (CPAN::Shell->expand("Module","/./")){
next unless $mod->inst_file;
# MakeMaker convention for undefined $VERSION:
next unless $mod->inst_version eq "undef";
print "No VERSION in ", $mod->id, "\n";
}
Macintosh-2:~ root# perl -MCPAN -e 'install CPAN::Shell'
Macintosh-2:~ root# ./update.no.version.sh
Can't locate object method "expand" via package "CPAN::Shell" (perhaps
you forgot to load "CPAN::Shell"?) at ./update.no.version.sh line 5.
Macintosh-2:~ root# which perl
/sw/bin/perl
Macintosh-2:~ root# perl -v
This is perl, v5.8.8 built for darwin-thread-multi-2level
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.
Macintosh-2:~ root# /sw/bin/perl -v
This is perl, v5.8.8 built for darwin-thread-multi-2level
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.
Macintosh-2:~ root# /sw/bin/perl -V
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
Platform:
osname=darwin, osvers=8.10.1, archname=darwin-thread-multi-2level
uname='darwin macintosh-2.local 8.10.1 darwin kernel version
8.10.1: wed may 23 16:33:00 pdt 2007; root:xnu-792.22.5~1release_i386
i386 i386 '
config_args='-des -Dcc=gcc -Dcpp=gcc -E -Dprefix=/sw
-Dccflags=-I/sw/include -Dldflags=-L/sw/lib -Dperladmin=none
-Uinstallusrbinperl -Dprivlib=/sw/lib/perl5-core/5.8.8
-Darchlib=/sw/lib/perl5-core/5.8.8/darwin-thread-multi-2level
-Dman3dir=/sw/lib/perl5-core/5.8.8/man/man3 -Dman3ext=3pm -Duseithreads
-Dinc_version_list=5.8.8/darwin-thread-multi-2level
5.8.6/darwin-thread-multi-2level 5.8.1 5.8.0 5.6.0
-Adefine:startperl=#!/sw/bin/perl5.8.8'
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=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-I/sw/include -fno-common -DPERL_DARWIN
-no-cpp-precomp -fno-strict-aliasing -pipe -Wdeclaration-after-statement
-I/usr/local/include -I/opt/local/include',
optimize='-O3',
cppflags='-no-cpp-precomp -I/sw/include -fno-common -DPERL_DARWIN
-no-cpp-precomp -fno-strict-aliasing -pipe -Wdeclaration-after-statement
-I/usr/local/include -I/opt/local/include'
ccversion='', gccversion='4.0.1 (Apple Computer, Inc. build 5367)',
gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags ='-L/sw/lib
-L/usr/local/lib -L/opt/local/lib'
libpth=/usr/local/lib /opt/local/lib /usr/lib
libs=-ldbm -ldl -lm -lc
perllibs=-ldl -lm -lc
libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-L/sw/lib -bundle -undefined
dynamic_lookup -L/usr/local/lib -L/opt/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT
PERL_MALLOC_WRAP USE_ITHREADS USE_LARGE_FILES
USE_PERLIO USE_REENTRANT_API
Built under darwin
Compiled at Aug 9 2007 21:52:20
@INC:
/sw/lib/perl5-core/5.8.8/darwin-thread-multi-2level
/sw/lib/perl5-core/5.8.8
/sw/lib/perl5/site_perl/5.8.8/darwin-thread-multi-2level
/sw/lib/perl5/site_perl/5.8.8
/sw/lib/perl5/site_perl/5.8.8/darwin-thread-multi-2level
/sw/lib/perl5/site_perl
.
Macintosh-2:~ root# which perl
/sw/bin/perl
Macintosh-2:~ root# ./update.no.version.sh
Can't locate object method "expand" via package "CPAN::Shell" (perhaps
you forgot to load "CPAN::Shell"?) at ./update.no.version.sh line 5.
Macintosh-2:~ root# /sw/bin/perl -V | less
Summary of my perl5 (revision 5 version 8 subversion 8) configuration:
Platform:
osname=darwin, osvers=8.10.1, archname=darwin-thread-multi-2level
uname='darwin macintosh-2.local 8.10.1 darwin kernel version
8.10.1: wed may 23
16:33:00 pdt 2007; root:xnu-792.22.5~1release_i386 i386 i386 '
config_args='-des -Dcc=gcc -Dcpp=gcc -E -Dprefix=/sw
-Dccflags=-I/sw/include -D
ldflags=-L/sw/lib -Dperladmin=none -Uinstallusrbinperl
-Dprivlib=/sw/lib/perl5-core
/5.8.8 -Darchlib=/sw/lib/perl5-core/5.8.8/darwin-thread-multi-2level
-Dman3dir=/sw/
lib/perl5-core/5.8.8/man/man3 -Dman3ext=3pm -Duseithreads
-Dinc_version_list=5.8.8/
darwin-thread-multi-2level 5.8.6/darwin-thread-multi-2level 5.8.1 5.8.0
5.6.0 -Adef
ine:startperl=#!/sw/bin/perl5.8.8'
hint=recommended, useposix=true, d_sigaction=define
usethreads=define use5005threads=undef useithreads=define
usemultiplicity=defin
e
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='gcc', ccflags ='-I/sw/include -fno-common -DPERL_DARWIN
-no-cpp-precomp -fn
o-strict-aliasing -pipe -Wdeclaration-after-statement
-I/usr/local/include -I/opt/l
ocal/include',
optimize='-O3',
cppflags='-no-cpp-precomp -I/sw/include -fno-common -DPERL_DARWIN
-no-cpp-preco
mp -fno-strict-aliasing -pipe -Wdeclaration-after-statement
-I/usr/local/include -I
/opt/local/include'
ccversion='', gccversion='4.0.1 (Apple Computer, Inc. build 5367)',
gccosandver
s=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags ='-L/sw/lib
-L/usr/local/lib
-L/opt/local/lib'
libpth=/usr/local/lib /opt/local/lib /usr/lib
libs=-ldbm -ldl -lm -lc
perllibs=-ldl -lm -lc
libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
gnulibc_version=''
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-L/sw/lib -bundle -undefined
dynamic_lookup -L/usr/l
ocal/lib -L/opt/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY PERL_IMPLICIT_CONTEXT
PERL_MALLOC_WRAP USE_ITHREADS USE_LARGE_FILES
USE_PERLIO USE_REENTRANT_API
Built under darwin
Compiled at Aug 9 2007 21:52:20
@INC:
/sw/lib/perl5-core/5.8.8/darwin-thread-multi-2level
/sw/lib/perl5-core/5.8.8
/sw/lib/perl5/site_perl/5.8.8/darwin-thread-multi-2level
/sw/lib/perl5/site_perl/5.8.8
/sw/lib/perl5/site_perl/5.8.8/darwin-thread-multi-2level
/sw/lib/perl5/site_perl
.
Jonasbn - 12 Aug 2007 19:17 GMT
Hi Noah,
You have to load the modules you intend to use prior to calling them
using the use statement
use CPAN::Shell;
and so forth. If you look at the error message
perhaps you forgot to load "CPAN::Shell
It gives you a hint. Check also:
% perldoc -f use
for a desciption of use.
% man perldiag
also holds a description of the error message.
jonasbn
--
AIM: BjonasN Gtalk: jonasbn@gmail.com
ICQ: 62401545 MSN: jonasbn@io.dk
> Hi,
>
[quoted text clipped - 215 lines]
> /sw/lib/perl5/site_perl
> .
Noah - 12 Aug 2007 19:33 GMT
thanks jonasbn,
but the module is still not located. what else am I doing wrong?
Macintosh-2:~ root# cat ./update.no.version.sh
#!/sw/bin/perl
use CPAN::Shell;
# install my favorite programs if necessary:
for $mod (qw(Net::FTP MD5 Data::Dumper)){
my $obj = CPAN::Shell->expand('Module',$mod);
$obj->install;
}
# list all modules on my disk that have no VERSION number
for $mod (CPAN::Shell->expand("Module","/./")){
next unless $mod->inst_file;
# MakeMaker convention for undefined $VERSION:
next unless $mod->inst_version eq "undef";
print "No VERSION in ", $mod->id, "\n";
}
# ./update.no.version.sh
Can't locate CPAN/Shell.pm in @INC (@INC contains:
/sw/lib/perl5-core/5.8.8/darwin-thread-multi-2level
/sw/lib/perl5-core/5.8.8
/sw/lib/perl5/site_perl/5.8.8/darwin-thread-multi-2level
/sw/lib/perl5/site_perl/5.8.8
/sw/lib/perl5/site_perl/5.8.8/darwin-thread-multi-2level
/sw/lib/perl5/site_perl .) at ./update.no.version.sh line 3.
BEGIN failed--compilation aborted at ./update.no.version.sh line 3.
jonasbn wrote:
> Hi Noah,
>
[quoted text clipped - 223 lines]
>> /sw/lib/perl5/site_perl
>> .
Jonasbn - 12 Aug 2007 19:39 GMT
Hi Noah,
My fault, CPAN::Shell is defined in CPAN
So you have to write use CPAN;
jonasbn
--
AIM: BjonasN Gtalk: jonasbn@gmail.com
ICQ: 62401545 MSN: jonasbn@io.dk
> thanks jonasbn,
>
[quoted text clipped - 277 lines]
>>> /sw/lib/perl5/site_perl
>>> .
Jeremiah Foster - 13 Aug 2007 13:01 GMT
> thanks jonasbn,
>
> but the module is still not located. what else am I doing wrong?
>
> Macintosh-2:~ root# cat ./update.no.version.sh
> #!/sw/bin/perl
This is confusing - you are writing a perl script but it ends in .sh?
Usually perl scripts end in .pl so that humans know it is a perl
script. I started debugging your script thinking it was shell.
> use CPAN::Shell;
>
[quoted text clipped - 3 lines]
> $obj->install;
> }
Since you now use "use CPAN::SHell" the expand now works. :)
> # list all modules on my disk that have no VERSION number
> for $mod (CPAN::Shell->expand("Module","/./")){
[quoted text clipped - 6 lines]
> # ./update.no.version.sh
> Can't locate CPAN/Shell.pm in @INC
Perl cannot find the package you downloaded called CPAN/Shell.pm. I
would be you used two methods to get your perl source:
fink and CPAN. If you use fink, fink stuffs things in /sw/, but CPAN
puts things in a different place. (See perldoc -q @INC.)
@INC is a set of perl libraries, only in perl they're called modules,
that you have on your system. You need to make sure that all the
modules that you downloaded are in @INC by telling perl where your
modules live. On my Mac I have perl modules in /sw/lib and in /usr/
lib/perl5/site_perl/ which is where Apple installed them.
Just make sure your @INC includes the CPAN::Shell.pm and you should
be okay.
> (@INC contains: /sw/lib/perl5-core/5.8.8/darwin-thread-
> multi-2level /sw/lib/perl5-core/5.8.8 /sw/lib/perl5/site_perl/5.8.8/
> darwin-thread-multi-2level /sw/lib/perl5/site_perl/5.8.8 /sw/lib/
> perl5/site_perl/5.8.8/darwin-thread-multi-2level /sw/lib/perl5/
> site_perl .) at ./update.no.version.sh line 3.
> BEGIN failed--compilation aborted at ./update.no.version.sh line 3.
Jeremiah Foster
jeremiah@jeremiahfoster.com
---
Key fingerprint = 9616 2AD3 3AE0 502C BD75 65ED BDC3 0D44 2F5A E672
Jonasbn - 14 Aug 2007 06:16 GMT
Hola,
Please note that the package CPAN::Shell lives in CPAN.pm, so the use
statement should read:
use CPAN;
Since the use statement reflect the filesystem (as described in the
@INC explanation below).
jonasbn
--
AIM: BjonasN Gtalk: jonasbn@gmail.com
ICQ: 62401545 MSN: jonasbn@io.dk
>> thanks jonasbn,
>>
[quoted text clipped - 53 lines]
> ---
> Key fingerprint = 9616 2AD3 3AE0 502C BD75 65ED BDC3 0D44 2F5A E672