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

The instructions for local::lib (using a bash shell) indicate putting the environment variable definitions into my .bashrc file.

However, my understanding is that .bashrc is used for non-login shells (sourced every time you open a new shell), so, the only things that belong in there are things that you want newly set for each shell (for example, maybe aliases, or setting $PS1).

AFAIK, the .profile file (sourced once when logging in) is for environment variables.

Should my local::lib settings go into my ~/.bashrc or ~/.profile?

Thanks.

  • Comment on Setting up with local::lib : .bashrc or .profile?

Replies are listed 'Best First'.
Re: Setting up with local::lib : .bashrc or .profile?
by almut (Canon) on Jun 02, 2010 at 18:48 UTC
    Should my local::lib settings go into my ~/.bashrc or ~/.profile?

    I don't think there's any one-size-fits-all answer to this question, as various (site/system/distro-specific) shell startup file policies are being used.  One common approach is to source .bashrc from the login profile (.profile), and then put the common stuff (i.e. what you want to have in both login and non-login interactive shells) in .bashrc, and any additional initialisations you want only for login shells in .profile.  In case this policy is in use, .bashrc would be the appropriate place to put the local::lib settings.

    Note also that there is a third "type" of shell - non-interactive - which by default doesn't read any startup files (but of course inherits the environment from where it's called). The latter is used to run commands via -c.  Also, the details vary widely from shell to shell... For bash-behavior, see the INVOCATION section in its man page.

Re: Setting up with local::lib : .bashrc or .profile?
by toolic (Bishop) on Jun 02, 2010 at 16:02 UTC
    local::lib

    This in no way answers the question; I just thought I'd provide a link to CPAN for those who are completely clueless as to what local::lib is (like me :)

Re: Setting up with local::lib : .bashrc or .profile?
by scorpio17 (Canon) on Jun 02, 2010 at 17:51 UTC
    I think it depends on what your default shell is. bash is not exclusively for "non-login" shells. The docs for local::lib show what to do IF you're using bash, as well as what to do if you're using csh. The default shell may vary depending on what flavor/version of unix/linux you're using.

      OT: I was surprised to find my distro (Ubuntu) uses a shell called dash. As a user I still have bash, but dash does all the startup stuff.

Re: Setting up with local::lib : .bashrc or .profile?
by Khen1950fx (Canon) on Jun 04, 2010 at 08:32 UTC
    Just a thought---you might be able to side-step the issue and use local::lib::deps. According to the docs, by doing like this,
    #!/usr/bin/perl use strict; use warnings; use local::lib::deps; my $moduledeps = local::lib::deps->new( base_path => '/path/to/custom/location', ); $moduledeps->install_deps( 'My::Module', 'Dep::One', 'Dep::Two');
    it'll create a directory specifically for the My::Module namespace, install the specified dependencies there, and setup local::lib there too.