jgravois's avatar

Valet is broken and won't let me reinstall

I started having trouble 6 days ago when I tried to install the spatie/media-library and needed to brew some packages. All seemed to work fine until later that day, I re-booted the mac and since then, I have been trying to get Valet to work again. Someone PLEASE help.

I uninstalled everything using these steps

brew uninstall jpegoptim
brew uninstall optipng
brew uninstall pngquant
brew uninstall svgo
brew uninstall gifsicle

valet uninstall
sudo brew services stop nginx
sudo brew services stop php70
sudo brew services stop dnsmasq
brew uninstall nginx
brew uninstall php70
brew uninstall dnsmasq
rm -rf ~/.valet
rm /usr/local/bin/valet

Then following the DOCS, I did the following:

brew update
brew install php

I then uninstalled and re-installed composer and moved it to /usr/local/bin/composer

composer global require laravel/valet
valet install

This is where I get stopped -- I get these two errors when I run valet install and then, the ping foobar.test test fails with ````cannot resolve foobar.test: Unknown host```.

I have "rinsed and repeated" the above several times this week and remain unable to continue.

0 likes
12 replies
rodrigo.pedra's avatar

Couple of things you can try:

  1. Clear composer cache

    $ composer clear-cache
    
  2. Remove any valet global files from composer

    $ rm -rf ~/.config/composer/vendor/laravel/valet
    

Note I am in linux so your composer global path might be different. If you don't know where the global composer folder is located try running

$ composer global update

And hit CTRL+C to stop the update. The first line in the output must be something like:

Changed current directory to /home/rodrigo/.config/composer

That is where your composer global files are located.

One alternative to manually removing the valet files would be trying to remove it globally:

$ composer global remove laravel/valet

Hope any of this helps you.

jgravois's avatar

thanks for trying.

composer clear-cache
composer global update
valet install

PATH: /Users/jgravois/.composer

ERRORS during Updating PHP configuration...:

Warning: file_get_contents(/usr/local/etc/php/7.3/php-fpm.d/www.conf): failed to open stream: No such file or directory in /Users/jgravois/.composer/vendor/laravel/valet/cli/Valet/Filesystem.php on line 112

Warning: file_put_contents(/usr/local/etc/php/7.3/php-fpm.d/www.conf): failed to open stream: No such file or directory in /Users/jgravois/.composer/vendor/laravel/valet/cli/Valet/Filesystem.php on line 125

Second Attempt --

composer clear-cache
rm -rf /Users/jgravois/.composer
composer global remove laravel/valet
composer clear-cache
composer global require laravel/valet
valet install

SAME ERROR

1 like
rodrigo.pedra's avatar

Well the error changed a bit, now it complains about not finding this file: /usr/local/etc/php/7.3/php-fpm.d/www.conf

Check if it exists:

$ ls /usr/local/etc/php/7.3/php-fpm.d/www.conf

If it does not exist, check you PHP version:

$ php -v

If you have more than one PHP version installed that might be the problem. In Linux I change the default version using the update-alternatives command, but don't know if that is possible with macOS.

Either way if the . conf file mentioned above does not exist in your system you might need to reinstall PHP.

===

Note: I saw you uninstalled php (brew uninstall php70) and then reinstalled with a different package name (brew install php) .

Do you know if this command brew install php installs both PHP CLI and PHP-FPM (which is used by nginx and valet to handle web requests)?

In Ubuntu I need to install both packages

$ sudo apt install php7.3 php7.3-fpm

Maybe you need to manually install the PHP-FPM from brew

jgravois's avatar

THANKS again for your help!

ls /usr/local/etc/php/7.3/php-fpm.d/www.conf
ls: /usr/local/etc/php/7.3/php-fpm.d/www.conf: No such file or directory
php -v
PHP 7.3.12 (cli) (built: Nov 21 2019 19:00:15) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.12, Copyright (c) 1998-2018 Zend Technologies

Trying to answer your other question

brew list | grep php
php
[email protected]

so, yes, there are multiple versions of php installed

rodrigo.pedra's avatar

So maybe php-fpm for php 7.3 is missing in your system.

As I am not a macOS user, I found this article:

https://panlw.github.io/15274361469556.html

Most of the steps you already have done. But this one caught my attention:

  brew tap homebrew/dupes && \
  brew tap homebrew/php && \
  brew install --without-apache --with-fpm --with-mysql php70

I guess you'd need to run somthing similar to the last line:

  brew install --without-apache --with-fpm --with-mysql php

So it gets the right modules. Take this advice with care, I am not familiar with brew. Do some research on how you can install missing PHP extensions through brew.

rodrigo.pedra's avatar

Oh, one more thing.

If you don't need multiple PHP versions installed, try removing the old ones.

jgravois's avatar

Tried the following (removing homebrew and re-installing):

sudo rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew update
brew install [email protected]
brew services start [email protected]
echo 'export PATH="/usr/local/opt/[email protected]/bin:$PATH"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/[email protected]/sbin:$PATH"' >> ~/.zshrc
source ~/.zshrc
composer global require laravel/valet
valet install

Now I get this:

valet install
Stopping nginx...
Installing nginx...
[nginx] is not installed, installing it now via Brew... 🍻
Installing nginx configuration...
Installing nginx directory...
Updating PHP configuration...

In Brew.php line 204:

  Homebrew PHP appears not to be linked.


install
rodrigo.pedra's avatar

After "sourcing" can you run PHP?

$ php -v

If it still doesn't work, try closing and reopening your terminal to "force-source".

The weirdest thing is that by your code the "composer global..." ran, which should be using the installed PHP version.

jgravois's avatar

PHP is fine when I run php artisan serve

and php -v give me

 ✈ php -v
PHP 7.2.25 (cli) (built: Nov 22 2019 10:25:54) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
jgravois's avatar

No worries. I am sure someone else in the community will try to help.

Thank you for your time and efforts.

1 like

Please or to participate in this conversation.