Short answer: The OP's prompt > cpan IPC::Run
indicates a standard macOS user level Perl module install. The stated error will occur if the standard environment variables appended to .zshrc
(or equivalent) by a cpan
first run .are.not. present in the runtime environment.
A macOS user level cpan IPC::Run
command can work OK, provided that …
- a new Terminal window is opened so that the expected Perl environment variables are present
- or, the missing environment variable lines are added to the Terminal resource file
.zshrc added lines
PATH="/Users/USERNAME/perl5/bin${PATH:+:${PATH}}"; export PATH;
PERL5LIB="/Users/USERNAME/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/Users/USERNAME/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/Users/USERNAME/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/Users/USERNAME/perl5"; export PERL_MM_OPT;
check active environment
echo $PATH
# /Users/USERNAME/perl5/bin:/usr/local/bin:…
set | grep ^PERL
# PERL5LIB=/Users/USERNAME/perl5/lib/perl5
# PERL_LOCAL_LIB_ROOT=/Users/USERNAME/perl5
# PERL_MB_OPT='--install_base "/Users/USERNAME/perl5"'
# PERL_MM_OPT='INSTALL_BASE=/Users/USERNAME/perl5'
TL;DR
Below are some findings for the question paraphrased as: "How to install and use CPAN modules with Apple's macOS Perl?"
Note: The details below were found & documented as a combination of both recreating & evaluating the OP's error, and of seeking to understand some issues I was also having with the macOS Perl cpan
installed modules on Ventura.
Apple's Pearl Customization
Apple's Perl (from early Mac OS X to at least macOS Ventura 13.4) has customizations. Information on these customizations is provided in the perlmacosx
manpage:

Apple's Perl customizations include:
AppendToPath
and PrependToPath
to add paths to the module search path (@INC
)
ARCHFLAGS
to build for multiple instruction set architectures
Install Location
The first run of cpan
will determine the base path for CPAN module installations.
cpan IPC::Run
# …
# CPAN.pm requires configuration, but most of it can be done automatically.
# …
# To install modules, you need to configure a local Perl library directory or
# escalate your privileges. CPAN can help you by bootstrapping the local::lib
# module or by configuring itself to use 'sudo' (if available). You may also
# resolve this problem manually if you need to customize your setup.
# What approach do you want? (Choose 'local::lib', 'sudo' or 'manual')
Resulting base install path, according to the prompted choice:
[local::lib]
- Users/USERNAME/Perl5
… default and OP's use case.
sudo
- /Library/Perl
manual
- /some/user/chosen/path
Module Use
An initial cpan
run (on clean a macOS Ventura Perl installation) includes the following "…append that to…" prompted question:
# …
# Appending installation info to /Users/USERNAME/perl5/lib/perl5/darwin-thread-multi-2level/perllocal.pod
#
# Would you like me to append that to /Users/USERNAME/.zshrc now? [yes]
# Running install for module 'IPC::Run'
# …
Notice that accepting the prompted [yes]
provides not additional information about what was appended or why. Easy to not pay much attention to this. Yet, look at what was appended…
.zshrc appended lines
PATH="/Users/USERNAME/perl5/bin${PATH:+:${PATH}}"; export PATH;
PERL5LIB="/Users/USERNAME/perl5/lib/perl5${PERL5LIB:+:${PERL5LIB}}"; export PERL5LIB;
PERL_LOCAL_LIB_ROOT="/Users/USERNAME/perl5${PERL_LOCAL_LIB_ROOT:+:${PERL_LOCAL_LIB_ROOT}}"; export PERL_LOCAL_LIB_ROOT;
PERL_MB_OPT="--install_base \"/Users/USERNAME/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/Users/USERNAME/perl5"; export PERL_MM_OPT;
If bosswrap.pl
is run in the same terminal window (without the .zshrc
updates), then the OP's error is recreated:
# ./Build install -- OK
./bosswrap.pl
# Can't locate IPC/Run.pm in @INC (you may need to install the IPC::Run module)
# (@INC contains: /Library/Perl/5.30/darwin-thread-multi-2level …
# … <snip> …
# …) at ./bosswrap.pl line 3.
# BEGIN failed--compilation aborted at ./bosswrap.pl line 3.
However, if a new terminal window is opened, which will have the .zshrc
updates applied, then bosswrap.pl
runs without error.
./bosswrap.pl
# silent return. no errors.
It appears that the OP's particular error scenario can be resolved by use of the provided PATH
, PERL5LIB
, PERL_LOCAL_LIB_ROOT
, PERL_MB_OPT
, and PERL_MM_OPT
in the runtime environment. Possibly by simply opening a new Terminal window for the appended values to take effect. Or, by manually adding the variables to the shell resource file, if the initial cpan
'… append that to …` step had been declined|missed.
In general, if one chooses to install Perl modules in a non-standard location, then
Apple provides a global mechanism to add @INC
search paths with AppendToPath
and PrependToPath
.

So, for macOS e.g. Ventura, there are two approaches for adding directories to the runtime include path (@INC)
without intrusion into the Perl script files.
- Environment variable:
PERL5LIB
- note that
PATH
, PERL_LOCAL_LIB_ROOT
, PERL_MB_OPT
, PERL_MM_OPT
also need to be properyly set.
- "/Library/Perl"
AppendToPath
|PrependToPath
system wide 3rd party modules
However, if one wishes to add @INC
search paths on an individual script basis, then the use lib qw(/some/other/path);
statement can be added to the Perl script itself.
Runtime Architecture
In general, a CPAN install is naive relative to the binaries that macOS might need for a native arm64
machine with rosetta x86_64
enabled. This is effectively a multi-architecture machine. An only-one-ISA-architecture install can result in runtime conflicts when one Perl application uses x86_64 and another Perl application uses arm64 (arm64e) for a Perl binary module common to both.
Some Perl CPAN Modules will install binary *.bundle
executables. For example, a Financle::Quote
module install will end up with 5 *.bundle
files.
#MY_PERL_INSTALL="/Library/Perl"
MY_PERL_INSTALL="/Users/USERNAME/Perl5"
find "$MY_PERL_INSTALL" -name "*.bundle"
# /Users/USERNAME/Perl5/lib/perl5/darwin-thread-multi-2level/auto/Test/LeakTrace/LeakTrace.bundle
# /Users/USERNAME/Perl5/lib/perl5/darwin-thread-multi-2level/auto/Date/Simple/Simple.bundle
# /Users/USERNAME/Perl5/lib/perl5/darwin-thread-multi-2level/auto/Sereal/Encoder/Encoder.bundle
# /Users/USERNAME/Perl5/lib/perl5/darwin-thread-multi-2level/auto/Sereal/Decoder/Decoder.bundle
# /Users/USERNAME/Perl5/lib/perl5/darwin-thread-multi-2level/auto/List/SomeUtils/XS/XS.bundle
Add the file
command to determine if the Perl module install tree has an inconsistent set of binary ISA slices:
MY_PERL_INSTALL="/Users/USERNAME/Perl5"
find "$MY_PERL_INSTALL" -name "*.bundle" | xargs file
# /Library/Perl/5.30/…/Readonly/XS/XS.bundle: Mach-O universal binary with 3 architectures: [x86_64:Mach-O 64-bit bundle x86_64] [arm64:Mach-O 64-bit bundle arm64] [arm64e:Mach-O 64-bit bundle arm64e]
# ...
# /Library/Perl/5.30/…/Date/Simple/Simple.bundle: Mach-O 64-bit bundle x86_64
# /Library/Perl/5.30/…/Sereal/Encoder/Encoder.bundle: Mach-O 64-bit bundle arm64
Apple's Perl customization provides the environment variable ARCHFLAGS
to allow Perl to install Universal Binary modules.

The ARCHFLAGS
can be used with cpan
as follows:
env ARCHFLAGS='-arch arm64 -arch arm64e -arch x86_64' cpan Test2
env ARCHFLAGS='-arch arm64 -arch arm64e -arch x86_64' cpan Finance::Quote
Note: If a non-universal binary install is already in place, that install will need to be uninstalled first because standard Perl install/update only checks the version number and not any underlaying ISA binary slices.
See Install & update a Perl module as "universal" (x86_64, arm64)? for more detailed Q&A on Universal Binary Perl modules.