Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

How to add path to @INC

by TSN (Acolyte)
on May 20, 2016 at 21:21 UTC ( #1163688=perlquestion: print w/replies, xml ) Need Help??

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

I'm trying install a module, e.g. 'installed', through cpan, however I got an error:

Can't locate TryCatch.pm in @INC

However TryCatch is installed but in a path that is not in @INC, TryCatch is in ~/.cpan/build/TryCatch-1.003002-0KBiDH/lib!

I see a lot of option as adding 'use lib...' on top of script Add 'export PERL5LIB=...' at bash

But is not what I need, I need that has effect on cpan!

Can you help me?

Replies are listed 'Best First'.
Re: How to add path to @INC
by runrig (Abbot) on May 20, 2016 at 22:10 UTC
    What directory is TryCatch installed in? Add that directory to 'use lib' or PERL5LIB. That will add it to @INC. If it's not in INC, perl won't find it.
      The path of TryCatch is ~/.cpan/build/TryCatch-1.003002-0KBiDH/lib! I'm not trying to run a script, so 'use lib' doesn´t work in this case! When I add trough PERL5LIB the path doesn't appear in @INC when I try install a module with cpan, PERL5LIB only works if I run a script that's need that module! So, has to be another way!
        > The path of TryCatch is ~/.cpan/build/TryCatch-1.003002-0KBiDH/lib!

        It seems like the path where your CPAN client built it, but it should then be installed somewhere else - /opt/perl, /usr/lib/perl, /usr/local/, ~/perl5, etc. Try searching for TryCatch harder.

        ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re: How to add path to @INC
by syphilis (Bishop) on May 21, 2016 at 00:59 UTC
    However TryCatch is installed but in a path that is not in @INC, TryCatch is in ~/.cpan/build/TryCatch-1.003002-0KBiDH/lib!

    As others have stated, it is not installed there - that is where it was built.
    And, if any of the tests failed, then it won't be installed at all unless you use force:
    cpan -fi TryCatch


    Adding ~/.cpan/build/TryCatch-1.003002-0KBiDH/lib to @INC will probably not work.
    It will enable TryCatch.pm to be found, but then the TryCatch loadable object (.so or .dll, depending upon platform) will not be found. For the loadable object to be found you probably need to also add ~/.cpan/build/TryCatch-1.003002-0KBiDH/blib/arch to @INC.
    This assumes that ~/.cpan/build/TryCatch-1.003002-0KBiDH/blib/arch/auto/TryCatch/TryCatch.so (or .dll) exists, and this is not necessarily the case.
    The existence of ~/.cpan/build/TryCatch-1.003002-0KBiDH/ indicates that an attempt to build and install TryCatch was made, but it doesn't tell us if it succeeded, or at what stage the process failed (if it did not succeed).

    Could you please run:
    cpan -i TryCatch
    and post the output.

    Cheers,
    Rob
        First problem occurs when building Scope::Upper (which is a TryCatch prerequisite):
        Upper.xs:1331:11: error: ‘CXt_LOOP_FOR’ undeclared (first use in this +function) case CXt_LOOP_FOR:
        Therefore Scope::Upper fails to build and does not get installed.
        Versions of perl prior to 5.24.0 define CXt_LOOP_FOR in cop.h, but not perl-5.24.0.
        But it's worse than that - see the bug report.
        That thread contains a patch which might solve your issue if you wish to apply it.

        TryCatch therefore fails its tests because Scope::Upper cannot be found.
        Therefore, TryCatch fails to install. You could force the installation but that won't help because TryCatch.pm needs to load Scope/Upper.pm and there's no way of installing a loadable Scope::Upper when it fails to build.

        I would take this up with the authors of these 2 modules.
        Does TryCatch *really* need to use Scope::Upper ?
        Maybe the Scope::Upper author would agree to upload a devel version of Scope::Upper that at least builds (despite his reservations about the mileage that would provide). It could be that the broken aspects of Scope::Upper don't impact on TryCatch.pm and it's just a matter of installing the patched version.

        Or you could consider using something else .... or revert to perl-5.22.x or earlier.

        Cheers,
        Rob
Re: How to add path to @INC
by Anonymous Monk on May 20, 2016 at 22:51 UTC
    use lib 'path/to/the/folder/that/holds/the/file';
      Thanks! But is not the solution that i'm seeking!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (6)
As of 2019-07-18 09:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?