Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Installing a Second perl

by Xiong (Hermit)
on Feb 20, 2010 at 19:17 UTC ( [id://824423]=perlquestion: print w/replies, xml ) Need Help??

Xiong has asked for the wisdom of the Perl Monks concerning the following question:

Background: I'm a solo dev; my current project is a web application. This issue concerns my local machine. My system (Ubuntu 9.10) requires perl to run; I suspect it figures heavily in some aspects of GNOME. Meanwhile, I wish to develop in Perl, and I downloaded many modules using cpan, eventually overwriting something used in the system UI and breaking it, which led to a clean OS install.

A couple Monks suggested that I not do that stupid thing; instead, that I install a second perl executable, with its own configurations and module library. This makes excellent sense. I wrote, "I will leave the system perl and its libraries alone; if I install an application that requires modules, I'll let Synaptic take care of the dependencies. I'll compile a distinct development perl somewhere else and use cpan to install whatever I like there." I felt silly for not doing this from Go.

Now, I've spent a full, 24-hour day trying to do just that. I downloaded the perl tarball from CPAN/src and walked through the install -- I thought with not too much trouble, succeeding on only the second try. Then I tried to get cpan working so I could install modules, the object of the exercise. I have utterly failed.

I have googled extensively on the topic, read docs on cpan itself and on Module::Build. I have edited MyConfig.pm directly and using o conf init. I have chowned and chgrped. All I appear to have done of lasting value, through carelessly doing sudo cpan at one point, is to pollute my system perl libraries again.

How does one install a second perl for development purposes?

I have two relevant folders, /lab and /ark. I want the development perl to be somewhere in the /lab path; I'm aiming for a hashbang line of #!/lab/bin/perl. I'd like that perl to search /lab/lib/perl only and for all modules associated with development to reside in that path only, except for project-specific modules which I will load in project scripts with use lib. I want all downloaded tarballs -- perl, perl modules, anything of that nature -- to be stored in /ark/perl, where they can be backed up at leisure. I'd prefer to be able to restore from tarballed backup (at least some of) the hundreds of modules I downloaded before pressing the Big Button. (My net connection is not the best, so redownloading is not always optimum.) I do not want to touch system perl for any reason; for that matter, I'd as soon download any tool the install requires and install it to /lab/bin, although that might be excessive.

I think I've got a good perl install along these lines but I'm not sure and don't know how to prove it. It runs a simple script, anyway. I'm pretty sure cpan is fubar. I've deleted all traces of the old .cpan folder, since I intend never to use cpan again to tinker with system perl. But I can't seem to eliminate all traces of cpan from both installs and start over.

I'm a tryer and a reader; I don't mind hard study. But most searches for "install perl", "install cpan" presume it's the first and only install; or the pages refer to obscure systems, installing under peculiar constraints, or the text is simply way out of date. Diligent examination of docs leads me down blind alleys. Searches for "install second perl executable", "install perl for development", and so forth founder on the common nature of the words.

Here's sample (abbreviated) output from cpan when trying to install Smart::Commentsfor the seventh time:

cpan[2]> install Smart::Comments CPAN: Storable loaded ok (v2.18) Going to read '/ark/cpan/Metadata' Database was generated on Sat, 20 Feb 2010 10:45:55 GMT Running install for module 'Smart::Comments' CPAN: YAML loaded ok (v0.71) Running make for C/CH/CHORNY/Smart-Comments-1.0.4.tar.gz CPAN: Digest::SHA loaded ok (v5.48) CPAN: Compress::Zlib loaded ok (v2.024) Checksum for /ark/cpan/sources/authors/id/C/CH/CHORNY/Smart-Comments-1 +.0.4.tar.gz ok ... (much output; looks good) ... Building Smart-Comments CHORNY/Smart-Comments-1.0.4.tar.gz ./Build --install_base /lab/perl --install_base /lab/perl -- OK Running Build test t/00.load.t ................. 1/1 # Testing Smart::Comments 1.0.4 t/00.load.t ................. ok ...(many more tests, ok)... All tests successful. Files=24, Tests=119, 1 wallclock secs ( 0.09 usr 0.03 sys + 1.17 cu +sr 0.11 csys = 1.40 CPU) Result: PASS CHORNY/Smart-Comments-1.0.4.tar.gz ./Build test -- OK Running Build install Prepending /ark/cpan/build/Smart-Comments-1.0.4-Sjn7Vr/blib/arch /ark/ +cpan/build/Smart-Comments-1.0.4-Sjn7Vr/blib/lib to PERL5LIB for 'inst +all' Building Smart-Comments !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! ERROR: Can't create '/usr/local/man/man3' Do not have write permissions on '/usr/local/man/man3' !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! +!! at /usr/local/share/perl/5.10.0/Module/Build/Base.pm line 3326 CHORNY/Smart-Comments-1.0.4.tar.gz ./Build install -- NOT OK ---- You may have to su to root to install the package (Or you may want to run something like o conf make_install_make_command 'sudo make' to raise your permissions.Failed during this command: CHORNY/Smart-Comments-1.0.4.tar.gz : install NO

...and we're back to the cpan prompt. This makes no sense to me. Okay, I've got the build taking place in /ark, which isn't best but it's tolerable for now.

But why is /usr/local/share/perl/5.10.0/Module/Build/Base.pm executing? How can I force cpan to work only from the new dev perl? Why the error trying to install man pages? I don't mean why does it fail; those are the system man page folders. I mean, why is it trying to do that?

Here's ~/.cpan/CPAN/MyConfig.pm:

$CPAN::Config = { 'applypatch' => q[], 'auto_commit' => q[1], 'build_cache' => q[2048], 'build_dir' => q[/ark/cpan/build], 'build_dir_reuse' => q[0], 'build_requires_install_policy' => q[yes], 'bzip2' => q[/bin/bzip2], 'cache_metadata' => q[1], 'check_sigs' => q[0], 'colorize_debug' => q[black on_white], 'colorize_output' => q[1], 'colorize_print' => q[black], 'colorize_warn' => q[bold red on_white], 'commandnumber_in_prompt' => q[1], 'connect_to_internet_ok' => q[1], 'cpan_home' => q[/ark/cpan], 'curl' => q[/usr/bin/curl], 'ftp' => q[/usr/bin/ftp], 'ftp_passive' => q[1], 'ftp_proxy' => q[], 'getcwd' => q[cwd], 'gpg' => q[/usr/bin/gpg], 'gzip' => q[/bin/gzip], 'halt_on_failure' => q[0], 'histfile' => q[/ark/cpan/histfile], 'histsize' => q[1000], 'http_proxy' => q[], 'inactivity_timeout' => q[0], 'index_expire' => q[1], 'inhibit_startup_message' => q[0], 'keep_source_where' => q[/ark/cpan/sources], 'load_module_verbosity' => q[v], 'lynx' => q[], 'make' => q[/usr/bin/make], 'make_arg' => q[], 'make_install_arg' => q[], 'make_install_make_command' => q[/usr/bin/make], 'makepl_arg' => q[LIB=/lab/perl/lib INSTALLMAN1DIR=/lab/perl/man/man +1 INSTALLMAN3DIR=/lab/perl/man/man3 INSTALLSCRIPT=/lab/bin INSTALLBIN +=/lab/bin], 'mbuild_arg' => q[--install_base /lab/perl], 'mbuild_install_arg' => q[], 'mbuild_install_build_command' => q[./Build], 'mbuildpl_arg' => q[--lib=/lab/perl/lib --installman1dir=/lab/perl/m +an/man1 --installman3dir=/lab/perl/man/man3 --installscript=/lab/bin +--installbin=/lab/bin], 'ncftp' => q[], 'ncftpget' => q[], 'no_proxy' => q[], 'pager' => q[/usr/bin/less], 'patch' => q[/usr/bin/patch], 'perl5lib_verbosity' => q[v], 'prefer_installer' => q[MB], 'prefs_dir' => q[/ark/cpan/prefs], 'prerequisites_policy' => q[follow], 'scan_cache' => q[atstart], 'shell' => q[/bin/bash], 'show_unparsable_versions' => q[0], 'show_upload_date' => q[0], 'show_zero_versions' => q[0], 'tar' => q[/bin/tar], 'tar_verbosity' => q[v], 'term_is_latin' => q[1], 'term_ornaments' => q[1], 'test_report' => q[0], 'trust_test_report_history' => q[0], 'unzip' => q[/usr/bin/unzip], 'urllist' => [q[ftp://cpan-sj.viaverio.com/pub/CPAN/], q[ftp://cpan. +erlbaum.net/CPAN/], q[ftp://cpan.hexten.net/], q[ftp://cpan.llarian.n +et/pub/CPAN/], q[ftp://cpan.mirrors.tds.net/pub/CPAN], q[ftp://cpan.n +etnitco.net/pub/mirrors/CPAN/], q[ftp://cpan.pair.com/pub/CPAN/], q[f +tp://cpan.uchicago.edu/pub/CPAN/], q[ftp://ftp-mirror.internap.com/pu +b/CPAN/], q[ftp://ftp.cise.ufl.edu/pub/mirrors/CPAN/], q[ftp://ftp.ep +ix.net/pub/languages/perl/], q[ftp://ftp.ncsu.edu/pub/mirror/CPAN/], +q[ftp://ftp.ndlug.nd.edu/pub/perl/], q[ftp://ftp.osuosl.org/pub/CPAN/ +], q[ftp://ftp.uwsg.iu.edu/pub/perl/CPAN/]], 'use_sqlite' => q[0], 'wget' => q[/usr/bin/wget], 'yaml_load_code' => q[0], 'yaml_module' => q[YAML], }; 1; __END__

Near as I can tell, I've specified where I want the dev module man pages; but those settings aren't respected. (The wrong Build.PL?)

I have a sneaking feeling that I'm missing some critical piece of information, something that prevents my report here from being comprehensive. If I'm told what to look for, I'll add it.

I'm prepared to set fire to the entire current install if I must but obviously, I'd be most grateful++ to the least intensive solution.

Update: Thanks to all for replies.

ikegami suggests one perl, two module libraries. That's a thought but I'd like to build dev perl with debugging and threading support. I think 753430 is a good pointer, though, to installing cpan in my case; thank you.

AriSoft's virtual computer approach may be above my level of expertise.

$ /lab/bin/perl -V
Summary of my perl5 (revision 5 version 10 subversion 1) configuration +: Platform: osname=linux, osvers=2.6.31-19-generic, archname=i686-linux uname='linux oz 2.6.31-19-generic #56-ubuntu smp thu jan 28 01:26: +53 utc 2010 i686 gnulinux ' config_args='' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=und +ef use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-DDEBUGGING -fno-strict-aliasing -pipe -fstack- +protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BIT +S=64', optimize='-O2 -g', cppflags='-DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector + -I/usr/local/include' ccversion='', gccversion='4.4.1', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=1 +2 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', + lseeksize=8 alignbytes=4, prototype=define Linker and Libraries: ld='cc', ldflags =' -fstack-protector -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib /usr/lib64 libs=-lnsl -ldl -lm -lcrypt -lutil -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc libc=/lib/libc-2.10.1.so, so=so, useshrplib=false, libperl=libperl +.a gnulibc_version='2.10.1' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -O2 -g -L/usr/local/lib -fs +tack-protector' Characteristics of this binary (from libperl): Compile-time options: DEBUGGING PERL_DONT_CREATE_GVSV PERL_MALLOC_WR +AP USE_FAST_STDIO USE_LARGE_FILES USE_PERLIO Built under linux Compiled at Feb 20 2010 06:21:34 @INC: /lab/lib/perl5/5.10.1 /lab/lib/perl5/5.10.1 .

Thanks redgreen! I think ./Configure -Dprefix=/lab leads the right way. I can study available options for that, too.

More:

JavaFan gets ++ for somewhat more detail. I don't need Daddy to hold my hand when I go p-p but a firm, friendly grip on my arm when I totter (dodder?) is highly welcome.

Upvoted Corion for seeing my perspective. My plan is to let all system components strictly alone, unless I mean to tinker with them. I'll play Engineer on remotehost; I may even rm its system perl and install a duplicate of my lab perl there. That should streamline things. If not, <plug>x10hosting.com tech support is extremely responsive.</plug>.

Replies are listed 'Best First'.
Re: Installing a Second perl
by ikegami (Patriarch) on Feb 20, 2010 at 19:55 UTC

    If you're ok with the system build you can install modules locally without building a whole new Perl. I have previously posted instructions.

    But why is /usr/local/share/perl/5.10.0/Module/Build/Base.pm executing?

    My guess is that you're executing the system's cpan or that it's executing your system's Perl. Make sure you're executing your own cpan, and make sure you its shebang line points to your own Perl. You shouldn't have to change any of cpan's configuration if the right tool is being used.

Re: Installing a Second perl
by syphilis (Archbishop) on Feb 20, 2010 at 23:44 UTC
    The problem is explained fairly clearly by the error messages. Running as user, you can't install to usr/local as you don't have permissions. The 'make install' phase needs to be run as root. Not sure how that is achieved using CPAN, but I would start with the suggested:
    o conf make_install_make_command 'sudo make'
    (You probably have to save that.) I guess, if that works, you'll be prompted for the root password before install takes place.

    Cheers,
    Rob
      Running as user, you can't install to usr/local as you don't have permissions. The 'make install' phase needs to be run as root.
      Not true. On almost all boxes I run, I install my own perl. Most of them don't need root access at all - except for the creation of a single directory. Here's a way the OP could do it:
      $ sudo mkdir /lab/perl $ sudo chown your_user_name: /lab/perl $ ... Fetch tarball ... $ ... Unpack tarball ... $ ... cd source directory ... $ ./Configure -des -Dprefix=/lab/perl $ make && make test && make install $ /lab/perl/bin/perl -MCPAN -eshell # Configure CPAN $ /lab/perl/bin/cpan -i Module1 Module2 Module3 Module4 ....
      No need to run any code downloaded from the internet as root. I typically create a dedicated "perladmin" user to manage the boxes perl and CPAN modules. /opt/perl is my favourite directory to install it in - with /usr/bin/perl a symlink to /opt/perl/bin/perl. (Making the symlink requires root access as well). If you're too scared to get rid to the "system perl"1, move /usr/bin/perl to /usr/bin/systemperl, and change the shebang line of any script that needs the "system perl" and fails on your own perl accordingly.
      1 After all, technology we don't understand is cannot be distinguished from magic.

        IMO it's less a matter of understanding and more a matter of separation of concerns. The system Perl is administered, configured (and tested, hopefully) by the OS vendor while the "other" Perl is administered and configured by you. You will soon enough have requirements (like threads for example) that differ from the requirements that the OS vendor has (speed for short running scripts) and that the OS vendor does not test for. Trying to bridge that gap without close integration with the OS vendor is a big endeavor if you're not dedicated to administrating a system.

Re: Installing a Second perl
by redgreen (Priest) on Feb 20, 2010 at 23:40 UTC

    What is the output from /lab/bin/perl -V ?

    When building your custom perl, you should have used something like:

    ./Configure -Dprefix=/lab

    This would configure everything to be stored under the /lab directory, including the man directory.

    Note: The CPAN install problem seems to be that it is trying to write to the '/usr/local/man/man3' directory, which is the big question here! It shouldn't be!

    And this must be build your own perl month — I have started building my own perl binaries as well for production, development and testing.

    Updated: thanks rowdog for catching the -d

      The CPAN install problem seems to be that it is trying to write to the '/usr/local/man/man3' directory, which is the big question here! It shouldn't be!

      Is there something wrong with that ? I have a perl that I built myself in /usr/local, and apart from having to install modules as root, there haven't been any problems.

      Cheers,
      Rob

        Well, that is fine for a /usr/local/ perl, but not for one that is configured for /lab like the OP is trying to do.

        It should be installing man pages into /lab/man which is what OP has permissions to use.

      The D should be capitalized, but yeah, this is a good start.

      ./Configure -Dprefix=/lab
Re: Installing a Second perl
by AriSoft (Sexton) on Feb 20, 2010 at 21:43 UTC
    Me, myself, wouldn't waste a second for trying to configure something which is not supposed to be done. Instead, when I tested my Perl scripts couple of days ago, I just started new virtual computer to my desktop and tested the script there using different operating system, not only different executable.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://824423]
Approved by AnomalousMonk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-03-29 06:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found