Search code examples
laravelmacoslaravel-10laravel-valetvalet

Laravel Valet Failed to open stream: Operation not permitted in



Warning: require(/Users/MY_USER_NAME/Documents/projects/example-app/public/index.php): Failed to open stream: Operation not permitted in /Users/MY_USER_NAME/.composer/vendor/laravel/valet/server.php on line 110

Fatal error: Uncaught Error: Failed opening required '/Users/MY_USER_NAME/Documents/projects/example-app/public/index.php' (include_path='.:/opt/homebrew/Cellar/php/8.3.1/share/php/pear') in /Users/MY_USER_NAME/.composer/vendor/laravel/valet/server.php:110 Stack trace: #0 {main} thrown in /Users/MY_USER_NAME/.composer/vendor/laravel/valet/server.php on line 110

Despite exhaustively exploring various solutions available on the internet, I attempted to resolve the issues by reinstalling Brew, Composer, and Valet.


Solution

  • I had been using the latest version of PHP, which was [email protected]. Recently, I decided to switch to PHP 8.2, and I followed the instructions provided on tecadmin.net. The guide I used for changing the PHP version can be found at https://tecadmin.net/install-php-macos/.
    https://laracasts.com/discuss/channels/general-discussion/getting-valet-not-found-error

    cd ~/.composer/
    sudo chown -R $(whoami) vendor
    

    and then

    rm -rf ~/.config/valet
    valet install
    valet use [email protected]