Skip to content
This repository was archived by the owner on Oct 18, 2025. It is now read-only.

Commit f5fd987

Browse files
committed
Use homebrew perl to run cpanm
cpanm needs to be run with the version of perl we want to install the modules into. For macOS, attempt to detect where cpanm is located and ensure it is run with the version of perl on the path.
1 parent 4e88fda commit f5fd987

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

install_cpan_modules.pl

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,28 @@
2727
push @modules, "Win32::Unicode::Process";
2828
}
2929

30+
# Command to use to run cpanm, default to the command directly
31+
$cpanm = "cpanm";
32+
33+
# On Mac, we want to run cpanm with the version of perl on the path -- which
34+
# should be the homebrew-installed version -- not whatever version cpanm is
35+
# pointing to which might be the one that came with macOS.
36+
if ( $^O eq 'darwin' ) {
37+
38+
# Intel
39+
if ( -e "/usr/local/bin/cpanm" ) {
40+
$cpanm = "perl /usr/local/bin/cpanm";
41+
}
42+
43+
# Apple Silicon
44+
elsif ( -e "/opt/homebrew/bin/cpanm" ) {
45+
$cpanm = "perl /opt/homebrew/bin/cpanm";
46+
}
47+
48+
# fall-through to using cpanm directly
49+
}
50+
3051
foreach my $module (@modules) {
31-
system("cpanm --notest $module") == 0
52+
system("$cpanm --notest $module") == 0
3253
or die("Failed trying to install $module\n");
3354
}

0 commit comments

Comments
 (0)