I’m helping a friend update their package to support Laravel 10 (and I’m learning Laravel along the way) and I keep getting Failed to open stream: No such file or directory
when Sail starts.
It’s trying to load the service provider file for ‘our’ package, but the error reads that it cannot find the file in question.
The file (GravityServiceProvider.php) is in the folder that Sail is complaining about (/var/www/html/vendor/composer/../bubalubs/gravity/src/).
I’ve tried deleting the composer.lock file, deleting the vendor folder and running composer install
and can see the package installs without errors. The package even completes any migrations needed. I tried clearing any compose cache. I tried running composer update after clearing cache, still no joy.
2
Answers
It's so glaringly obvious now after trying the
file_exists()
andis_readable()
whilst using Sail. A small detail I left out was the package was in a folder outside of the project. So yes, PHP could 'see' the file hence it passed thefile_exists()
check, but Sail couldn't read it as it was outside of the container.I've moved the package into a
packages
folder inside of the project, and referenced that instead. Getting different errors now, but they seem to relate to the actual codebase of the package and not file/permission related.You have to publish your provider. Follow this instructions found here if it’s correct package https://github.com/Bubalubs/gravity