Skip Menu |

This queue is for tickets about the local-lib CPAN distribution.

Report information
The Basics
Id: 130567
Status: new
Priority: 0/
Queue: local-lib

People
Owner: Nobody in particular
Requestors: dabe [...] dabe.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Duplicate Directory Deleted (After 'sudo')
In my '.bashrc' I have: test -d "$HOME/perl5" && eval "$(perl -Mlocal::lib="$HOME/perl5")" I've also configured 'sudo' to --preserve-env (including disabling 'always_set_home' in /etc/sudoers). Anyway, when I "sudo -s", I end up with: dabe% env | grep PERL PERL5LIB=/home/dabe/perl5/lib/perl5 PERL_MB_OPT=--install_base "/home/dabe/perl5" PERL_LOCAL_LIB_ROOT=/home/dabe/perl5 PERL_MM_OPT=INSTALL_BASE=/home/dabe/perl5 dabe% sudo -s Password: ************ root# env | grep PERL PERL5LIB=/home/dabe/perl5/lib/perl5 PERL_MB_OPT=--install_base "/home/dabe/perl5" PERL_LOCAL_LIB_ROOT=/home/dabe/perl5:/home/dabe/perl5 PERL_MM_OPT=INSTALL_BASE=/home/dabe/perl5 i.e., "PERL_LOCAL_LIB_ROOT" includes a duplicate entry. [Which may be a whole 'nother issue entirely...] The problem is, if I have a script that does: use local::lib '/home/dabe/perl5'; It ends up seeing that "/home/dabe/perl5" is in @active_lls[1 .. $#active_lls], AND DEACTIVATING IT, so I'm left with: unset PERL5LIB unset PERL_LOCAL_LIB_ROOT PERL_MB_OPT=--install_base "/home/dabe/perl5" PERL_MM_OPT=INSTALL_BASE=/home/dabe/perl5 My quick-and-dirty solution was simply to "uniq" the list of active_paths() in 'sub activate': [Maybe it would be fine to move it into 'sub active_paths', directly, but I only wanted to touch as few moving parts as necessary...] --- a/local/lib.pm 2017-10-08 11:21:28.000000000 -0400 +++ b/local/lib.pm 2019-09-24 10:32:54.000000000 -0400 @@ -296,6 +296,11 @@ ); } +sub _uniq { + my %seen; + grep { !$seen{$_}++ } @_; +} + sub active_paths { my ($self) = @_; $self = ref $self ? $self : $self->new; @@ -370,7 +375,7 @@ $path = $self->normalize_path($path); - my @active_lls = $self->active_paths; + my @active_lls = _uniq($self->active_paths); if (grep { $_ eq $path } @active_lls[1 .. $#active_lls]) { $self = $self->deactivate($path); Anyway, like I say, maybe a better solution would be to squash the duplicates before they end up in PERL_LOCAL_LIB_ROOT in the first place, but this worked for me. «grin» Ta!
Subject: local-lib.patch
--- a/local/lib.pm 2017-10-08 11:21:28.000000000 -0400 +++ b/local/lib.pm 2019-09-24 10:32:54.000000000 -0400 @@ -296,6 +296,11 @@ ); } +sub _uniq { + my %seen; + grep { !$seen{$_}++ } @_; +} + sub active_paths { my ($self) = @_; $self = ref $self ? $self : $self->new; @@ -370,7 +375,7 @@ $path = $self->normalize_path($path); - my @active_lls = $self->active_paths; + my @active_lls = _uniq($self->active_paths); if (grep { $_ eq $path } @active_lls[1 .. $#active_lls]) { $self = $self->deactivate($path);