Skip to content

Instantly share code, notes, and snippets.

@LiosK
Last active December 17, 2023 10:14
Show Gist options
  • Save LiosK/acef3b100a7096f8f9c7b0d1c98cf9c8 to your computer and use it in GitHub Desktop.
Save LiosK/acef3b100a7096f8f9c7b0d1c98cf9c8 to your computer and use it in GitHub Desktop.
Install Perl modules in macOS system Perl without cluttering /usr/local
#!/bin/bash -x
# Install Perl modules in macOS system Perl without cluttering /usr/local
# Prerequisite
xcode-select --install
# Install modules locally, instructing cpanm to build Universal Binaries
sysperl=/usr/bin/perl
curl -L https://cpanmin.us/ | \
ARCHFLAGS='-arch arm64 -arch arm64e -arch x86_64' \
$sysperl - -n --local-lib=~/.sys_perl5 \
JSON::Parse https://github.com/LiosK/Finance--Quote--YahooJapan.git
# NOTE: persist these env vars to have sysperl and FQ load local libs and YahooJapan
export PERL5LIB="$HOME/.sys_perl5/lib/perl5"
export FQ_LOAD_QUOTELET='-defaults YahooJapan'
# Test
$sysperl -e 'print "$_\n" for @INC;'
$sysperl ~/.sys_perl5/bin/fetch_quotes_from_yahoo_japan.pl
@LiosK
Copy link
Author

LiosK commented Nov 4, 2017

Motivations:

  • Modules need to be installed in system Perl to be loaded on GUI apps
  • cpan --sudo module_name puts some script and document files under /usr/local, which conflict with Homebrew Perl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment