Reputation: 1
I'm writing a step-by-step instruction guide to installing perlbrew on a newly built (from ISO) MacOS Big Sur (11.4) VM running on VMware Fusion.
I have been able to successfully install perlbrew. Here is what perlbrew info looks like:
perlbrew info
Current perl: Using system perl. Shebang: #!/usr/bin/perl
perlbrew: version: 0.92 ENV: PERLBREW_ROOT: /Users/jblaty/perl5/perlbrew PERLBREW_HOME: /Users/jblaty/.perlbrew PERLBREW_PATH: /Users/jblaty/perl5/perlbrew/bin PERLBREW_MANPATH:
Great! Now, I'll do perlbrew switch perl-5.32.1 and then another perlbrew info:
perlbrew info
Current perl: Name: perl-5.32.1 Path: /Users/jblaty/perl5/perlbrew/perls/perl-5.32.1/bin/perl Config: -de -Dprefix=/Users/jblaty/perl5/perlbrew/perls/perl-5.32.1 -Aeval:scriptdir=/Users/jblaty/perl5/perlbrew/perls/perl-5.32.1/bin Compiled at: Jun 23 2021 14:43:45
perlbrew: version: 0.92 ENV: PERLBREW_ROOT: /Users/jblaty/perl5/perlbrew PERLBREW_HOME: /Users/jblaty/.perlbrew PERLBREW_PATH: /Users/jblaty/perl5/perlbrew/bin:/Users/jblaty/perl5/perlbrew/perls/perl-5.32.1/bin PERLBREW_MANPATH: /Users/jblaty/perl5/perlbrew/perls/perl-5.32.1/man
Super! So I'm now running the perlbrew version of Perl in the VM. Here is what the path looks like now that I've switched...
print $PATH
/Users/jblaty/perl5/perlbrew/bin:/Users/jblaty/perl5/perlbrew/perls/perl-5.32.1/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
AWESOME! So in the path, MacOS finds the perlbrew version before the system version of Perl. Everything looks great so far, but I expect that a perlbrew switch to be persistent to each new terminal session I start. Keep in mind that I'm using zsh, and my .zshenv looks like this:
cat .zshenv
source ~/perl5/perlbrew/etc/bashrc
However, here's where things break. If I close that terminal session and open a new one, and then do another perlbrew info, here's what I get:
perlbrew info
Current perl: Name: perl-5.32.1 Path: /Users/jblaty/perl5/perlbrew/perls/perl-5.32.1/bin/perl Config: -de -Dprefix=/Users/jblaty/perl5/perlbrew/perls/perl-5.32.1 -Aeval:scriptdir=/Users/jblaty/perl5/perlbrew/perls/perl-5.32.1/bin Compiled at: Jun 23 2021 14:43:45
perlbrew: version: 0.92 ENV: PERLBREW_ROOT: /Users/jblaty/perl5/perlbrew PERLBREW_HOME: /Users/jblaty/.perlbrew PERLBREW_PATH: /Users/jblaty/perl5/perlbrew/bin:/Users/jblaty/perl5/perlbrew/perls/perl-5.32.1/bin PERLBREW_MANPATH: /Users/jblaty/perl5/perlbrew/perls/perl-5.32.1/man
...everything looks just fine, right? However, if I have another look at the path:
print $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/jblaty/perl5/perlbrew/bin:/Users/jblaty/perl5/perlbrew/perls/perl-5.32.1/bin
WRONG! The perlbrew bin directories are appended to the end of the path, not the beginning as it was before I closed the terminal session, earlier.
Can anyone guide me as to:
What did I do wrong? Did I miss something in the install?
How do I fix perlbrew so the perlbrew bin paths gets prepended to the system paths in subsequent new terminal sessions?
I'm going to be creating instructions for Linux as well, so fixing this might help me understand what I need to do there.
Upvotes: 0
Views: 228
Reputation: 531
Add the initialization script to ~/.zshrc
.
echo 'source ~/perl5/perlbrew/etc/bashrc' >> ~/.zshrc
The zsh startup file order is:
/etc/zshenv
~/.zshenv
/etc/zprofile
<- system PATH
set here~/.zprofile
/etc/zshrc
~/.zshrc
/etc/zlogin
~/zlogin
Upvotes: 1