Valet requires Homebrew to be installed on your Mac

369 Views Asked by At

I'm trying to install Valet following an official Laravel documentation. So I installed Homebrew first by using:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"`

I can confirm it was installed by running which brew which returns /opt/homebrew/bin/brew.

Installed PHP 8.2 by running brew install php.

PHP 8.2.8 (cli) (built: Jul  6 2023 10:57:44) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.2.8, Copyright (c) Zend Technologies
    with Zend OPcache v8.2.8, Copyright (c), by Zend Technologies

Installed Composer by running the following:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'e21205b207c3ff031906575712edab6f13eb0b361f2085f1f1237b7126d785e826a450292b6cfd1d64d92e6563bbde02') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

and then sudo mv composer.phar /usr/local/bin/composer.

I can tell that the ~/.composer/vendor/bin directory is definitely in my system's "PATH" by running echo $PATH which returns:

/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/CyberArk EPM.app/Contents/Helpers:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/galopom/WebDev/galopom/node_modules/.bin:/Users/galopom/.composer/vendor/bin

After Composer has been installed, I installed Laravel Valet as a global Composer package:

composer global require laravel/valet

But when I run valet install I get Valet requires Homebrew to be installed on your Mac..

Apple M1 Pro, MacOS - 13.4.1 (22F82)

I'm literally spinning in circles, could anyone please help?!

2

There are 2 best solutions below

0
Boss COTIGA On

I prefer use bash, go to Terminal preferences to change zsh to bash

Don't use SUDO for move composer.phar to /usr/local/bin/composer !

THEN add this code in your .bash_profile

# BREW
export PATH="/usr/local/sbin:$PATH"

# COMPOSER
export PATH="/Users/YOUR_USER_NAME/.composer/vendor/bin:$PATH"

# NODE ET NPM
export PATH="/usr/local/bin:$PATH"
export PATH="/Users/YOUR_USER_NAME/.npm-packages/bin:$PATH"
unset NODE_OPTIONS

# MYSQL VIA BREW
export PATH="/usr/local/opt/mysql/bin:$PATH"

# PHP VIA BREW
export PATH="/usr/local/opt/[email protected]/bin:$PATH"
export PATH="/usr/local/opt/[email protected]/sbin:$PATH"
export LDFLAGS="-L/usr/local/opt/[email protected]/lib"
export CPPFLAGS="-I/usr/local/opt/[email protected]/include"
0
lechat On

brew for apple chip is installed in /opt, but this path is not working for valet, so after uninstalling everything installed by the apple-chip-brew and uninstalling the apple-chip-brew itself and deleting all PATH of the brew, then I followed this:
https://dev.to/ibrarturi/mac-m1-setup-for-local-development-with-laravel-valet-2lmk

I installed:

arm brew install php 
arm brew install composer

Now I removed the valet installed by the apple-chip-composer then re-installed valet:

composer global remove laravel/valet 
composer global require laravel/valet

Now valet is working in my apple chip PC.

valet -v                             
Laravel Valet 4.3.0