Baadier's avatar

Getting Valet - Not Found error

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.

0 likes
15 replies
Jorge's avatar

Same problem here, Did you find a solution?

Baadier's avatar

Hi @Jorge

I ended up having to reinstall as I had installed with sudo which caused the issues.

You can see the /var/root/.... in the folder structure and then the other complaints from /Users/Username which is caused by incorrect permissions.

1 like
Jorge's avatar

I ended up editing the file ~/.composer/vendor/laravel/valet/server.php and hardcoded the VALET_HOME_PATH and now its working.

umefarooq's avatar

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.

cd ~/.composer/

sudo chown -R $(whoami) vendor

now happy development with valet.

30 likes
umefarooq's avatar

@Baadier your welcome, this is for future reference, or anybody else facing same problem.

3 likes
ejdelmonico's avatar

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.

1 like
fcoble's avatar

@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!

ecomevo's avatar

Unfortunately sudo chown -R $(whoami) ~/.composer/vendor didn't work for me for this exact issue. What else could be going on here?

ecomevo's avatar

This series of commands fixed the issue:

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)

1 like
timgavin's avatar

Could you edit your post so that the commands are on their own line? it's very hard to read what's going on here. Thank you.

2 likes

Please or to participate in this conversation.