moderated >> borken CPAN on OS X

by miah_gbg » Mon, 25 Jul 2005 20:38:42 GMT

Hello,

CPAN is being very unfriendly. I am running it from the command line
thusly;

# perl -MCPAN -e 'install LWP::UserAgent'

and it is replying

"Can't locate object method "install" via package "LWP::UserAgent" at
-e line 1."

I have tried to enter the CPAN shell and install, reset my conf files,
chown the .cpan directory and many other things, but for me CPAN is
just broken. The CPAN web site has not been much help and searching
this newsgroup for informatin on CPAN yields two year old messages. Is
there anyone out there with similar experiences who got CPAN to work?

Many thanks,

Jeremiah

moderated >> borken CPAN on OS X

by Mark Jason Dominus » Mon, 25 Jul 2005 22:10:37 GMT



Short answer: Use

perl -MCPAN -e 'install("LWP::UserAgent")'

instead.


The 'install LWP::UserAgent' notation is a bit of a cheat, because it
is ambiguous.

It might mean

install('LWP::UserAgent')

which is what you want, but it could also be interpreted as

LWP::UserAgent->install()

which is not what you want. How does Perl decide?

There are several criteria Perl uses. For example, if the current
program has loaded a module named 'LWP::UserAgent', Perl choses the
second interpretation; if not, it choses the first.

Usually, when you run "perl -MCPAN -e 'install Foo'" you are not also
using the module Foo at the same time, because it is not installed
yet, so Perl will assume that you meant "install('Foo')". So
usually you can leave out the punctuation and everything works OK.

But in this case, you do already have the LWP::UserAgent module
installed, and the CPAN module has loaded it, because CPAN.pm is
planning to use it to download files! So the other interpretation is
chosen.

I hope this was helpful.

moderated >> borken CPAN on OS X

by Gaal Yahas » Mon, 25 Jul 2005 22:43:36 GMT


Use a quoted string, not a bareword:

perl -MCPAN -e 'install "LWP::UserAgent"'

--
Gaal Yahas < XXXX@XXXXX.COM >
http://gaal.livejournal.com/

moderated >> borken CPAN on OS X

by miah_gbg » Tue, 26 Jul 2005 04:37:49 GMT

Yes, that was very helpful, thank you. I have run into other errors
however and am thinking about moving towards another solution.

Thanks for the reply.

moderated >> borken CPAN on OS X

by brian d foy » Thu, 28 Jul 2005 00:39:16 GMT

In article < XXXX@XXXXX.COM >, Mark Jason Dominus



or just

$ cpan LWP::UserAgent

--
brian d foy, XXXX@XXXXX.COM
Subscribe to The Perl Review: http://www.theperlreview.com

Similar Threads

1. cpan module installation on Mac OS Leopard

I'm having trouble with a Perl script. I installed Mac::Growl through
CPAN. It worked, but seemed to copy the final files to a place that
doesn't exist. I can't find it now. When I run my script, it says it
can't find Mac::Growl in @INC. How can I get CPAN to install modules
into directories that exist in @INC?

I'm using the perl and cpan that came with Mac OS Leopard.

2. solved - OS X, cpan, libnet - Perl

3. OS X, cpan, libnet

Hello all,

I have perl 5.6.0 on my Mac OS X.  I'd like to install libnet.  
However, when I try to use cpan, it wants to automagically upgrade my 
perl to 5.8.2.  All I really want is Net::FTP.  What is my best course 
of action:

- upgrade to perl 5.8.2 and then libnet-1.17
- upgrade to some other perl version (5.6.1, 5.8.0, 5.8.1).  If so, 
then what libnet version should I install?
- stay with perl 5.6.0.  If so, which libnet version should I install?  
Within cpan, an 'i /libnet/' returns 1.17 and 1.0703 for tar files.
- forget about libnet, just install Net:FTP.  If so, which version and 
from where?
- use fink to install perl modules.  If so, how?

Any words of perl wisdom and pointers in the right direction are 
greatly appreciated.

Regards,
- Robert

4. CPAN Shell on Mac OS X (10.3) Not Installing Modules

5. Trouble with readline in cpan, perl debug on Mac OS X

I have reinstalled cpan, and the readline libraries, but even though 
cpan says readline is enabled, it doesn't work right.  Also the perl 
debugger has a similar problem.  Could it be that the Perl that is 
installed from the Apple site is not readline enabled?  Below is the 
perl -V output.  Thanks for any help you can give me.

Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
   Platform:
     osname=darwin, osvers=5.5, archname=darwin
     uname='darwin mercury 5.5 darwin kernel version 5.5: thu may 30 
14:51:26 pdt 2002; root:xnuxnu-201.42.3.obj~1release_ppc power macintosh 
powerpc '
     config_args='-Dprefix=/opt/perl'
     hint=recommended, useposix=true, d_sigaction=define
     usethreads=undef use5005threads=undef useithreads=undef 
usemultiplicity=undef
     useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
     use64bitint=undef use64bitall=undef uselongdouble=undef
     usemymalloc=n, bincompat5005=undef
   Compiler:
     cc='cc', ccflags ='-pipe -fno-common -no-cpp-precomp 
-fno-strict-aliasing',
     optimize='-O3',
     cppflags='-no-cpp-precomp -pipe -fno-common -no-cpp-precomp 
-fno-strict-aliasing'
     ccversion='', gccversion='2.95.2 19991024 (release)', 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='cc', ldflags =' -flat_namespace'
     libpth=/usr/lib
     libs=-lm -lc
     perllibs=-lm -lc
     libc=/usr/lib/libc.dylib, so=dylib, useshrplib=true, 
libperl=libperl.dylib
     gnulibc_version=''
   Dynamic Linking:
     dlsrc=dl_dyld.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
     cccdlflags=' ', lddlflags=' -flat_namespace -bundle -undefined 
suppress'

Characteristics of this binary (from libperl):
   Compile-time options: USE_LARGE_FILES
   Built under darwin
   Compiled at Jul 19 2002 18:12:13
   %ENV:
     PERL5LIB="/sw/lib/perl5:/sw/lib/perl5/darwin"
     PERLDOC_PAGER="less"
   @INC:
     /sw/lib/perl5/darwin
     /sw/lib/perl5
     /sw/lib/perl5/darwin
     /opt/perl/lib/5.8.0/darwin
     /opt/perl/lib/5.8.0
     /opt/perl/lib/site_perl/5.8.0/darwin
     /opt/perl/lib/site_perl
     .


6. "cpan" command prompt on Mac OS X - Perl

7. OS X, installing modules from CPAN

I'm using OS X (10.4.10), I've installed a few modules system wide with:

sudo -H cpan -i Module::Name

I'd like to look at the build directory, there are some examples of the
module in use. The problem is, I can't find .cpan in /root... there is
no /root! 

Does anyone know where, under OS X, .cpan is? Not a user one, the one
that would be under /root on a Linux system.

	Justin.

-- 
Justin C, by the sea.

8. [OT cpan] How to paginate cpan output when inside cpan shell - Perl