'No application encryption key has been specified but it has been

i keep getting the following error.

[2022-03-09 08:30:49] production.ERROR: No application encryption key has been specified. {"exception":"[object] (Illuminate\\Encryption\\MissingAppKeyException(code: 0): No application encryption key has been specified. at /Users/XXX/Documents/GijsCode/mfg/dashboard-mfg/vendor/laravel/framework/src/Illuminate/Encryption/EncryptionServiceProvider.php:101)
[stacktrace]

This is weird because on my ubuntu pc where i mainly develop i didnt get this error. Now iam working on a mac and i cant seem to get rid of the error.

i have tried clearing the cache and generating it again but the error occurs when running the command php artisan key:generate

Error message when running php artisan key:generate

/.env): Failed to open stream: No such file or directory

  at vendor/laravel/framework/src/Illuminate/Foundation/Console/KeyGenerateCommand.php:96
     92▕     {
     93▕         file_put_contents($this->laravel->environmentFilePath(), preg_replace(
     94▕             $this->keyReplacementPattern(),
     95▕             'APP_KEY='.$key,
  ➜  96▕             file_get_contents($this->laravel->environmentFilePath())
     97▕         ));
     98▕     }
     99▕ 
    100▕     /**

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

I hope anyone knows the answer to this bug because I'am absolutely clueless.

EDIT:

I fixed it by hardcoding the path into the config file.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source