I ran into an issue with MAMP 4 using PHP 5.6.27 or 7.0.12 and WP CLI 0.25.0 using 5.6.25 by default. According to the WP CLI docs, to use MAMP’s version of PHP, I should prepend my $PATH
with:
PHP_VERSION=ls /Applications/MAMP/bin/php/ | sort -n | tail -1
export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH
I’m using Oh My ZSH and when I add that to my .zshrc
file, I have:
export PATH="~/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
# Homebrew
export PATH=/usr/local/Homebrew/:$PATH
# Use MAMP's version of PHP.
PHP_VERSION=ls /Applications/MAMP/bin/php/ | sort -n | tail -1
export PATH=/Applications/MAMP/bin/php/${PHP_VERSION}/bin:$PATH
Now, when I run source .zshrc
or open a new terminal window to use the new configuration, I get an error /Users/USERNAME/.zshrc:60: permission denied: /Applications/MAMP/bin/php/
.
I’ve tried modifying the MAMP directory with chown
and that doesn’t seem to be the issue. My .zshrc
file in the home directory is symlinking to a dot files directory elsewhere, but I tried placing it directly in ~/
without success.
Any ideas why I might be getting that permissions error?
PHP_VERSION=ls /Applications/MAMP/bin/php/ | sort -n | tail -1
should be
PHP_VERSION=$(ls /Applications/MAMP/bin/php/ | sort -n | tail -1)