Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

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 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 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/ (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.

        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 needs to load Scope/ 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 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.

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?

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2020-08-09 05:43 GMT
Find Nodes?
    Voting Booth?
    Which rocket would you take to Mars?

    Results (54 votes). Check out past polls.