Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nixos (and others) compatibility #801

Merged
merged 3 commits into from
Jun 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.99
- Thanks to our contributors: Joelle Maslak
- bashrc executes properly in bash shells with +h option set
- Allow specification of non-standard Perl location

0.98
- Released at 2023-08-11T22:54:38+0900
- Remove the support of cperl from `available` and `install` command. Github PR: #777. cperl can still be installed by specifying the tarball, just not by their short names.
Expand Down
3 changes: 2 additions & 1 deletion META.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"Test::Output" : "1.03",
"Test::Simple" : "1.001002",
"Test::Spec" : "0.49",
"Test::TempDir::Tiny" : "0.016"
"Test::TempDir::Tiny" : "0.016",
"Test::Which" : "1.27"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does not look like Test::Which is directly used in the new test, we can probably remove this change.

Actually I pretty much just depend on mbtiny to generate META.json / META.yml for me these days...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting... CI failed at missing Test::Switch. I guess I'll need to tweak how I use mbtiny a little bit to accommodate this addition.

}
}
},
Expand Down
9 changes: 8 additions & 1 deletion lib/App/perlbrew.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2881,7 +2881,9 @@ __perlbrew_purify () {
__perlbrew_set_path () {
export MANPATH=${PERLBREW_MANPATH:-}${PERLBREW_MANPATH:+:}$(__perlbrew_purify "$(manpath 2>/dev/null)")
export PATH=${PERLBREW_PATH:-$PERLBREW_ROOT/bin}:$(__perlbrew_purify "$PATH")
hash -r
if [ -o hashall ] ; then
hash -r
fi
Comment on lines +2887 to +2889
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A very nice little detail that I've been missing... thanks for adding this!

}

__perlbrew_set_env() {
Expand Down Expand Up @@ -3431,6 +3433,11 @@ As a result, different users on the same machine can all share the same perlbrew
root directory (although only original user that made the installation would
have the permission to perform perl installations.)

If you need to install perlbrew using a Perl that isn't either C</usr/bin/perl>
or C</usr/local/bin/perl>, set and export the environment variable
C<PERLBREW_SYSTEM_PERL> and then install as described above. Note that you
must not use a perlbrew-managed perl.

You may also install perlbrew from CPAN:

cpan App::perlbrew
Expand Down
5 changes: 3 additions & 2 deletions perlbrew-install
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ echo
echo "## Installing perlbrew"

# loop thru available well known Perl installations
for PERL in "/usr/bin/perl" "/usr/local/bin/perl"
for PERL in "/usr/bin/perl" "/usr/local/bin/perl" "$PERLBREW_SYSTEM_PERL"
do
[ -x "$PERL" ] && echo "Using Perl <$PERL>" && break
[ -n "$PERL" ] && [ -x "$PERL" ] && echo "Using Perl <$PERL>" && break
done

if [ ! -x "$PERL" ]; then
echo "Need /usr/bin/perl or /usr/local/bin/perl to use $0"
echo "Alternatively, set PERLBREW_SYSTEM_PERL to point at system perl"
clean_exit 2
fi

Expand Down
38 changes: 38 additions & 0 deletions t/bashrc_executes.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/usr/bin/env perl
use strict;
use warnings;

use FindBin;
use lib $FindBin::Bin;
use App::perlbrew;
require 'test_helpers.pl';

use Test::More;
use Capture::Tiny qw( capture_stderr );
use File::Which qw( which );

note "PERLBREW_ROOT set to $ENV{PERLBREW_ROOT}";

subtest "Works without error output on bash where hashing is off", sub {
my $bash = which("bash");
if (!defined($bash)) {
plan skip_all => "Bash executable not found, skipping this test.";
return;
}

my $app = App::perlbrew->new('self-install');
$app->current_shell("bash");
$app->run;

my $ret;
my $out = capture_stderr {
my $bash_init = file($ENV{PERLBREW_ROOT}, "etc", "bashrc");
system("ls $ENV{PERLBREW_ROOT}/etc/bashrc");
$ret = system($bash, "+h", "-c", "source $bash_init");
};
is($out, "", "No error messages in output");
is($ret, 0, "Return value proper");
};


done_testing;
Loading