fclose(): Argument #1 ($stream) must be of type resource, bool given

Viewed 17259

I just restart my laravel 8.0 project and I got this below error, please what could be wrong, this happens anytime I run "PHP artisan serve"

   TypeError

  fclose(): Argument #1 ($stream) must be of type resource, bool given

  at C:\Users\owner\Laravel-App\test-app\vendor\symfony\process\Pipes\WindowsPip
es.php:74
     70▕                         fclose($this->lockHandles[$pipe]);
     71▕                     }
     72▕                     $this->lockHandles[$pipe] = $h;
     73▕
  ➜  74▕                     if (!fclose(fopen($file, 'w')) || !$h = fopen($file
, 'r')) {
     75▕                         flock($this->lockHandles[$pipe], \LOCK_UN);
     76▕                         fclose($this->lockHandles[$pipe]);
     77▕                         unset($this->lockHandles[$pipe]);
     78▕                         continue 2;
       continue 2;

  1   C:\Users\owner\Laravel-App\test-app\vendor\symfony\process\Pipes\WindowsPi
pes.php:74
      fclose()

  2   C:\Users\owner\Laravel-App\test-app\vendor\symfony\process\Process.php:130
4
      Symfony\Component\Process\Pipes\WindowsPipes::__construct()
10 Answers

You can open the task manager then look for CLI (with the php logo) background process, if you find it then the kill task

I had a Laravel application running that I forgot about (in the terminal of another IDE). Ctl + C (killing) that allowed me to get past this error msg.

I had the same error today and applied all the solutions but this resolved my error.

  1. Un-install the composer.
  2. Restart your machine
  3. Install the composer

Don't restart, don't uninstall, don't panic !

If you are on Windows Machine then follow these below step :

  1. Click the Start charm.

  2. Type cmd, right-click the Command Prompt tile, and then click Run as administrator.

  3. Type tasklist /v | find "php" press enter and find the PID of php.exe

  4. Kill the process by taskkill /PID <PID> /F

  5. You are done.

First run composer install before trying to start the dev server using php artisan serve. You might also have to generate the key using php artisan key:generate incase the app starts with errors.

I encountered same issues I hope this solution help someone else:

1. Delete the **vendor** folder/directory of the project
2. run **"composer install"** to install packages.

That fixed my issues.

I've solved this issue by searching the process that was keeping open the file sf_proc_00.err within %LOCALAPPDATA%\Temp (the local Windows temp directory). Process Explorer or similar tools can be used for this. It was locked by ssh.exe (very likely launched by git). After killing the process, composer runs normally again.

Just Stop/Shoutdown Artisan Server

It's work for me

You should clear the config cache using optimize:clear command:

php artisan optimize:clear

The solution is very easy, just do

php artisan config:clear

Then rerun

php artisan serve
Related