Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php artisan config:cache error #41613

Closed
Tofandel opened this issue Mar 22, 2022 · 8 comments · Fixed by #41614
Closed

php artisan config:cache error #41613

Tofandel opened this issue Mar 22, 2022 · 8 comments · Fixed by #41614

Comments

@Tofandel
Copy link
Contributor

Tofandel commented Mar 22, 2022

  • Laravel Version: 9.5.1
  • PHP Version: 8.0.16
  • Database Driver & Version: Mariadb but doesn't matter

Description:

Steps To Reproduce:

Just run php artisan config:cache a bunch of times, around 1 out of 2 times (if it was already cached) the following error appears

Configuration cache cleared successfully.

   ErrorException

  require(releases/55a338ab2cb555eb6a03cbcdd176d1f1473d89ef/bootstrap/cache/config.php): Failed to open stream: No such file or directory

  at vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/LoadConfiguration.php:28
     24▕         // First we will see if we have a cache configuration file. If we do, we'll load
     25▕         // the configuration items from that file so that it is very quick. Otherwise
     26▕         // we will need to spin through every configuration file and load them all.
     27▕         if (is_file($cached = $app->getCachedConfigPath())) {
  ➜  28▕             $items = require $cached;
     29▕
     30▕             $loadedFromCache = true;
     31▕         }
     32▕

      +18 vendor frames
  19  artisan:37
      Illuminate\Foundation\Console\Kernel::handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

This seems to be a problem with opcache.enable_file_override which caches the result of is_file

@driesvints
Copy link
Member

Hi there,

Thanks for reporting but it looks like this is a question which can be asked on a support channel. Please only use this issue tracker for reporting bugs with the library itself. If you have a question on how to use functionality provided by this repo you can try one of the following channels:

However, this issue will not be locked and everyone is still free to discuss solutions to your problem!

Thanks.

@driesvints
Copy link
Member

I don't think this is an issue with Laravel or we should be seeing way more reports for this. Please try a support channel. Thanks

@Tofandel
Copy link
Contributor Author

Tofandel commented Mar 22, 2022

It is but with a specific configuration

With opcache.enable_file_override = 1 in your php ini

Then is_file is cached the first time, but then the second time it's called the require fails because it doesn't actually exist, though a fix is really easy with a try {} catch around the require

@driesvints
Copy link
Member

Feel free to attempt that fix if you want 👍

@crynobone
Copy link
Member

If you want to use OpCache on CLI mode, the deployment flow (where you run config:cache) should also clear OpCache. Otherwise you will see other issues between deployment.

Tool such as https://gordalina.github.io/cachetool/ should be useful.

@Tofandel
Copy link
Contributor Author

Tofandel commented Mar 22, 2022

@crynobone But in this case the problem is both is_file happens during the same command, so clearing the cache before will not change anything

Basically running the command loads the config on bootsrap, so is_file was cached and will now return true for the rest of the script
The cache file is unlinked
The cache is regenerated and for this it loads the config again with the call to is_file which is true and triggers the error

And in fact If I ran php artisan config:clear && php artisan config:cache this issue would not happen because they're considered two requests so the is_file cache is invalidated in between

@crynobone
Copy link
Member

@Tofandel
Copy link
Contributor Author

Tofandel commented Mar 22, 2022

Not sure what I am supposed to take from this article?

I'm talking about https://www.php.net/manual/en/opcache.configuration.php#ini.opcache.enable-file-override

And I have validate_timestamp set to 1, but the issue is the is_file is still cached until the end of the request as it should (in this case the end of the script)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants