Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

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).

Thnx!

Comment on PERL5LIB resets in a new terminal window
Re: PERL5LIB resets in a new terminal window
by toolic (Bishop) 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 http://mactip.blogspot.com/2004/04/setting-environment-variables.html 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 Terminal.app 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.

    -derby
      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 Terminal.app 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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (8)
As of 2015-07-06 08:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls