I'm trying to get Valet running on my Mac and I'm getting a Valet - Not Found error.
Warning: file_get_contents(/var/root/.valet/config.json): failed to open stream: Permission denied in /Users/Username/.composer/vendor/laravel/valet/server.php on line 23
Warning: Invalid argument supplied for foreach() in /Users/Username/.composer/vendor/laravel/valet/server.php on line 47
404 - Not Found
There is only a basic html file in the directory im trying.
if you have installed composer global package using sudo than file owner will be root, in server.php it is checking file owner and then setting VALET_HOME_PATH, you need to change owner ship of all global packages or laravel/valet only. better to change for all so next time composer update or install without sudo.
On a side note, you should not have to use sudo when running anything for development such as composer, node, npm, yarn, gulp, etc. If you do, you have installed packages with the wrong permissions. When installing a package, the package is installed with the permissions of the user. So, if you used sudo to install, root will own the package which means you will have to use sudo when running. It is obvious why using sudo is dangerous for your system. However, you can easily fix the problem by changing ownership to your user. Then, the package will assume your user's permissions.
@UMEFAROOQ - Great answer. I did this in a haste and looking at my command history I realized immediately what I had done. Searching the error I immediately found this thread and you saved me much time figuring out how to actually correct the error. Awesome!
brew uninstall composer
rm -rf ~/.composer
valet uninstall
rm -rf ~/.config/valet
valet unsecure --all
brew update
brew install composer
composer global require laravel/valet
valet install
valet park (on site dir)
valet secure (in repo dir)