Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

PERL5LIB resets in a new terminal window

by colicab (Initiate)
on Apr 27, 2012 at 19:20 UTC ( #967703=perlquestion: print w/ replies, xml ) Need Help??
colicab has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks.

I'm quite new at Perl programming. I just did some courses on basic Perl, BioPerl and using the Perl API to search the Ensembl database. So if this is a noob question/problem, you know why that is ;-)

I want to install the Perl API and for that the tutorial on the Ensembl webpage says you have to set PERL5LIB environment variable by doing this: export PERL5LIB=/src/ensembl/modules:/src/ensembl-compara/modules:/src/ensembl-variation/modules:/src/ensembl-functgenomics/modules:

So far so good: when I echo $PERL5LIB, I nicely get the list I just set in the env variable. I can run my scripts and everything is great!

But now, when I close the current terminal window and open it again, he empties the PERL5LIB list and I have to set them again. After that, it works again until I try it with yet a new Terminal window.

Is this normal behaviour? I thought, you had to set the variable once and it's done? How can I permanently set PERL5LIB? Can anyone help me with this? BTW, I'm working on a macbook Air running OS X 10.7.3 (Lion) with perl 5.12.3. I don't know if you guys need to know something else about my system...

I googled for this problem but I didn't find any helpful links (although before this problem, I ran into a bunch of other problem trying to install the API. So I might have been a bit impatient with googling).


Comment on PERL5LIB resets in a new terminal window
Re: PERL5LIB resets in a new terminal window
by toolic (Chancellor) on Apr 27, 2012 at 19:28 UTC
    In a unix environment you can set environment variables in a set up file which gets run every time you open a new shell. The file name (.bashrc, .cshrc) varies depending on the shell you use.

    I don't have a Mac, but googling 'mac environment' yeilds which mentions a .MacOSX/environment.plist file.

Re: PERL5LIB resets in a new terminal window
by JavaFan (Canon) on Apr 27, 2012 at 19:30 UTC
    Is this normal behaviour?
    Yes. Note, this is not a Perl issue. The only way environment variables are "shared" is that when a process forks, both parent and child get identical copies. And on an exec, the environment persists.
    How can I permanently set PERL5LIB?
    Set it in the process that spawns the xterms. Or by setting it in the shell profile that's run each time an xterm starts.
Re: PERL5LIB resets in a new terminal window
by derby (Abbot) on Apr 27, 2012 at 19:57 UTC

    Unless you've changed it, the default shell in Lion is bash. So to set PERL5LIB, just fireup and vi .bashrc and add this line to it

    PERL5LIB=/src/ensembl/modules:/src/ensembl-compara/modules:/src/ensemb +l-variation/modules:/src/ensembl-functgenomics/modules

    Now everytime you open a terminal (or tab) your environment should have PERL5LIB set.

      Hi. Thanks a lot for all the feedback. I did as derby proposed is it works now. It's seems its the .profile instead of the .bashrc file I had to edit.

      Thanks Monks :-)

        Unless you've changed your shell in the preferences, either would have been fine. OS X is mostly BSD Unix underneath. Something like 90% of the tutorials and solutions online for Linux will apply and you can get that even higher by learning how to use MacPorts to install non-standard/missing tools.

        hii dear... I am facing the similar problem and getting the same error like cannot locate at @INC. Please help me.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2014-09-19 22:42 GMT
Find Nodes?
    Voting Booth?

    How do you remember the number of days in each month?

    Results (150 votes), past polls