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

ok so I installed mac ports recently.

It then added this line into my .bash_profile

# MacPorts Installer addition on 2013-01-17_at_18:11:48: adding an app +ropriate PATH variable for use with MacPorts. export PATH=/opt/local/bin:/opt/local/sbin:$PATH

And now when I try to run lets say my dancer app, it goes and says:

Can't locate YAML.pm in @INC (@INC contains: /Users/gideon/Documents/C +oding/TryPerlMain/TryPerlApp/lib /opt/local/lib/perl5/site_perl/5.12. +4/darwin-thread-multi-2level /opt/local/lib/perl5/site_perl/5.12.4 /o +pt/local/lib/perl5/vendor_perl/5.12.4/darwin-thread-multi-2level /opt +/local/lib/perl5/vendor_perl/5.12.4 /opt/local/lib/perl5/5.12.4/darwi +n-thread-multi-2level /opt/local/lib/perl5/5.12.4 /opt/local/lib/perl +5/site_perl /opt/local/lib/perl5/vendor_perl .) at /opt/local/lib/per +l5/site_perl/5.12.4/Dancer/ModuleLoader.pm line 31, <DATA> line 1003.

If I comment the line out everything sort of works. But now because of this mishap I probably installed double copies of some modules on my opt/localand on my regular modules directory. (I'm generally new to perl and osx)

Questions:

  1. Can I live without local lib thing? It's my personal computer and I just want the regular installations, I'm happy with sudo cpan
  2. Will mac ports NOT work with that line commented?

Replies are listed 'Best First'.
Re: I installed mac ports and now all my cpan dependencies cannot be found
by Anonymous Monk on Jan 26, 2013 at 09:44 UTC

    Can I live without local lib thing?

    Yup, the local/lib thing is for folks who can't/won't  sudo cpan

    Will mac ports NOT work with that line commented?

    It probably won't, not if that is the only way it gets into $PATH

      Thanks for the reply. So this is a mac ports problem. I'll do more digging on their forums then....

      Do you see any quick way out? Or I would have to change my .bash_profile everytime I use macports?

        gideondsouza:

        If you start the macports program with a script, you could always just add a command to set the path for that process. In bash, for example, you could just add an export PATH=... line before starting macports. I don't know how you would do that for a program started from an icon, but I'll bet you can do it if you dig through the docs. That way, macports can use it's version of perl, and for all your other work, you can use your version.

        You could always do the opposite, too, removing the /opt/local directory from your path before invoking your perl scripts. In fact, that's what I do at work. I have perl linked to a script that does a bit of bookkeeping, and it removes a couple of things from the path before starting up. I'm at home right now, but if I recall correctly, it was something like:

        #!/usr/bin/bash # My local perl libraries export PERL5LIB=/home/roboticus/LIB # Log when & what I run CURDTM=`date +'%Y%m%d-%H%M'` echo $CURDTM $@ >>~/.runlog # my perl executable Krevulax $@

        As I mentioned, it's from memory. I don't care for bash scripting, so I don't recall the tricky bits like parameter mucking, so I expect that I've misremembered the line that passes the shell parameters to perl, but this should give you the general idea.

        Just to satisfy any curiosity about "Why does he log the date and time of every script he runs?": My job is so crazy and I'm always jumping from task to task. Thus, I have a huge set of perl scripts littered around my machine. So when someone asks me "Hey, remember that thingamajig you did for me three weeks ago? Could you do it again for me?" I sometimes couldn't easily find it. So I added the logging and wrote a little report for myself that will list the different scripts I've run for a given date range. Once I recognize the name (I *do* try to give meaningful names to the scripts), I'm a simple "locate scriptname" away from it.

        ...roboticus

        When your only tool is a hammer, all problems look like your thumb.

        Thanks for the reply. So this is a mac ports problem. I'll do more digging on their forums then....

        I don't see how. In one perl you installed some module, but didn't install it in another perl.

        Do you see any quick way out?

        install the module using the mac ports perl

        Or I would have to change my .bash_profile everytime I use macports?

        Usually you change $PATH once, permanently, and then you're finished