Laravel Sail - Failed to open stream: Permission denied

Photo by Mark König on Unsplash

Laravel Sail - Failed to open stream: Permission denied

A fresh Laravel Sail installation is getting the error Failed to open stream: Permission denied whenever when we go to localhost or run artisan command such as: sail artisan make:model

Turns out that Sail was running as 'sail' user but my WSL is running as root user:

A quick solution to this is just chown everything in sail container back to 'sail' user:

# Console to sail as root
sail root-shell
# chown everything in /var/www/html back to sail
chown -R sail:sail ./*