Skip to content

Instantly share code, notes, and snippets.

@1mursaleen
Last active August 14, 2023 18:00
Show Gist options
  • Save 1mursaleen/b54a61e04cab319a5e24816035f9390e to your computer and use it in GitHub Desktop.
Save 1mursaleen/b54a61e04cab319a5e24816035f9390e to your computer and use it in GitHub Desktop.
Fixing Valet Permission Errors

Issue:

When encountering the following errors:

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

Solution:

These errors are related to permissions and ownership of files, particularly when using globally installed Composer packages with sudo. The server.php script in the laravel/valet package checks the file owner to set the VALET_HOME_PATH. To resolve this, you can adjust the ownership of either all global packages or specifically the laravel/valet package. It is recommended to change ownership for all global packages to avoid potential issues with future Composer updates or installations without sudo.

To change ownership of the global Composer packages, follow these steps:

  1. Open a terminal window.
  2. Navigate to the Composer directory:
    cd ~/.composer/
  3. Change ownership of the vendor directory to your current user:
    sudo chown -R $(whoami) vendor

Reference:

For more detailed discussion on this issue and solution, you can visit: https://laracasts.com/discuss/channels/general-discussion/getting-valet-not-found-error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment