gugod/App-perlbrew — pull request #180 by kmcgrath (2011-12-26 23:09:13+00:00)
Title: reset local::lib on multiple use

$PATH and other $ENV variables are not clean when use is run multiple times for different libs.

Example:

$ perlbrew use perl-5.14.2@proj1
$ echo $PATH
/home/Kevin/.perlbrew/libs/perl-5.14.2@proj1/bin:/home/Kevin/perl5/perlbrew/bin:/home/Kevin/perl5/perlbrew/perls/perl-5.14.2/bin:/usr/local/bin:/usr/bin:/usr/local/bin:/usr/bin:/cygdrive/c/PROGRA~1/COMMON~1/MICROS~1/WINDOW~1:/cygdrive/c/PROGRA~2/COMMON~1/MICROS~1/WINDOW~1:/cygdrive/c/PROGRA~2/AMDAPP~1/bin/x86_64:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WINDOW~1/v1.0:/cygdrive/c/PROGRA~1/Intel/WiFi/bin:/cygdrive/c/PROGRA~1/COMMON~1/Intel/WIRELE~1:/cygdrive/c/PROGRA~2/ATITEC~1/ATI.ACE/CORE-S~1:/cygdrive/c/PROGRA~2/Intel/Services/IPT:/cygdrive/c/PROGRA~2/Symantec/VIPACC~1:/cygdrive/c/PROGRA~2/Sony/VAIOST~1:/cygdrive/c/PROGRA~2/COMMON~1/ROXIOS~1/10.0/DLLSHA~1:/cygdrive/c/PROGRA~2/COMMON~1/ROXIOS~1/DLLSHA~1:/cygdrive/c/PROGRA~2/WIC4A1~1/Shared:/cygdrive/c/STRAWB~1/5.12/c/bin:/cygdrive/c/STRAWB~1/5.12/perl/site/bin:/cygdrive/c/STRAWB~1/5.12/perl/bin:/cygdrive/c/STRAWB~1/5.14/c/bin:/cygdrive/c/STRAWB~1/5.14/perl/site/bin:/cygdrive/c/STRAWB~1/5.14/perl/bin

$ perlbrew use perl-5.14.2@proj2
$ echo $PATH
/home/Kevin/.perlbrew/libs/perl-5.14.2@proj2/bin:/home/Kevin/perl5/perlbrew/bin:/home/Kevin/perl5/perlbrew/perls/perl-5.14.2/bin:/home/Kevin/.perlbrew/libs/perl-5.14.2@proj1/bin:/usr/local/bin:/usr/bin:/usr/local/bin:/usr/bin:/cygdrive/c/PROGRA~1/COMMON~1/MICROS~1/WINDOW~1:/cygdrive/c/PROGRA~2/COMMON~1/MICROS~1/WINDOW~1:/cygdrive/c/PROGRA~2/AMDAPP~1/bin/x86_64:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WINDOW~1/v1.0:/cygdrive/c/PROGRA~1/Intel/WiFi/bin:/cygdrive/c/PROGRA~1/COMMON~1/Intel/WIRELE~1:/cygdrive/c/PROGRA~2/ATITEC~1/ATI.ACE/CORE-S~1:/cygdrive/c/PROGRA~2/Intel/Services/IPT:/cygdrive/c/PROGRA~2/Symantec/VIPACC~1:/cygdrive/c/PROGRA~2/Sony/VAIOST~1:/cygdrive/c/PROGRA~2/COMMON~1/ROXIOS~1/10.0/DLLSHA~1:/cygdrive/c/PROGRA~2/COMMON~1/ROXIOS~1/DLLSHA~1:/cygdrive/c/PROGRA~2/WIC4A1~1/Shared:/cygdrive/c/STRAWB~1/5.12/c/bin:/cygdrive/c/STRAWB~1/5.12/perl/site/bin:/cygdrive/c/STRAWB~1/5.12/perl/bin:/cygdrive/c/STRAWB~1/5.14/c/bin:/cygdrive/c/STRAWB~1/5.14/perl/site/bin:/cygdrive/c/STRAWB~1/5.14/perl/bin

Notice that after running use for proj2 paths for proj1 still exist.

## Fix
Use the build_deact_all_environment_vars_for function in local::lib to reset

$ perlbrew use perl-5.14.2@proj1
$ echo $PATH
/home/Kevin/.perlbrew/libs/perl-5.14.2@proj1/bin:/home/Kevin/perl5/perlbrew/bin:/home/Kevin/perl5/perlbrew/perls/perl-5.14.2/bin:/usr/local/bin:/usr/bin:/usr/local/bin:/usr/bin:/cygdrive/c/PROGRA~1/COMMON~1/MICROS~1/WINDOW~1:/cygdrive/c/PROGRA~2/COMMON~1/MICROS~1/WINDOW~1:/cygdrive/c/PROGRA~2/AMDAPP~1/bin/x86_64:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WINDOW~1/v1.0:/cygdrive/c/PROGRA~1/Intel/WiFi/bin:/cygdrive/c/PROGRA~1/COMMON~1/Intel/WIRELE~1:/cygdrive/c/PROGRA~2/ATITEC~1/ATI.ACE/CORE-S~1:/cygdrive/c/PROGRA~2/Intel/Services/IPT:/cygdrive/c/PROGRA~2/Symantec/VIPACC~1:/cygdrive/c/PROGRA~2/Sony/VAIOST~1:/cygdrive/c/PROGRA~2/COMMON~1/ROXIOS~1/10.0/DLLSHA~1:/cygdrive/c/PROGRA~2/COMMON~1/ROXIOS~1/DLLSHA~1:/cygdrive/c/PROGRA~2/WIC4A1~1/Shared:/cygdrive/c/STRAWB~1/5.12/c/bin:/cygdrive/c/STRAWB~1/5.12/perl/site/bin:/cygdrive/c/STRAWB~1/5.12/perl/bin:/cygdrive/c/STRAWB~1/5.14/c/bin:/cygdrive/c/STRAWB~1/5.14/perl/site/bin:/cygdrive/c/STRAWB~1/5.14/perl/bin

$ perlbrew use perl-5.14.2@proj2
$ echo $PATH
/home/Kevin/.perlbrew/libs/perl-5.14.2@proj2/bin:/home/Kevin/perl5/perlbrew/bin:/home/Kevin/perl5/perlbrew/perls/perl-5.14.2/bin:/usr/local/bin:/usr/bin:/usr/local/bin:/usr/bin:/cygdrive/c/PROGRA~1/COMMON~1/MICROS~1/WINDOW~1:/cygdrive/c/PROGRA~2/COMMON~1/MICROS~1/WINDOW~1:/cygdrive/c/PROGRA~2/AMDAPP~1/bin/x86_64:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WINDOW~1/v1.0:/cygdrive/c/PROGRA~1/Intel/WiFi/bin:/cygdrive/c/PROGRA~1/COMMON~1/Intel/WIRELE~1:/cygdrive/c/PROGRA~2/ATITEC~1/ATI.ACE/CORE-S~1:/cygdrive/c/PROGRA~2/Intel/Services/IPT:/cygdrive/c/PROGRA~2/Symantec/VIPACC~1:/cygdrive/c/PROGRA~2/Sony/VAIOST~1:/cygdrive/c/PROGRA~2/COMMON~1/ROXIOS~1/10.0/DLLSHA~1:/cygdrive/c/PROGRA~2/COMMON~1/ROXIOS~1/DLLSHA~1:/cygdrive/c/PROGRA~2/WIC4A1~1/Shared:/cygdrive/c/STRAWB~1/5.12/c/bin:/cygdrive/c/STRAWB~1/5.12/perl/site/bin:/cygdrive/c/STRAWB~1/5.12/perl/bin:/cygdrive/c/STRAWB~1/5.14/c/bin:/cygdrive/c/STRAWB~1/5.14/perl/site/bin:/cygdrive/c/STRAWB~1/5.14/perl/bin

## Also
* I had to add Capture::Tiny to update-fatlib.pl
* I use perlbrew when messing with perlbrew. I have a local::lib for each perl project I work on. When using dev-bin I had to change build.sh so it would not blow away my PERL5LIB.