Skip to content

Compile broken on Windows since 4.6.8 #1574

@8ctopus

Description

@8ctopus

Bug report

Compile is broken on Windows since 4.6.8, works fine with 4.6.7

| ------------| ---------------
| Box version | 4.6.10
| PHP version | 8.4.14
| Platform with version | Windows 10 Pro Version 22H2 OS Build 19045.6575

$ php box-4.6.10.phar compile
Xdebug: [Step Debug] Time-out connecting to debugging client, waited: 200 ms. Tried: localhost:9000 (through x
debug.client_host/xdebug.client_port).

    ____
   / __ )____  _  __
  / __  / __ \| |/_/
 / /_/ / /_/ />  <
/_____/\____/_/|_|


Box version 4.6.10@6dc6a13 2025-10-31 18:40:22 UTC

 // Loading the configuration file "K:\dev\github\php-webp8\box.json".

�  Building the PHAR "K:/dev/github/php-webp8/bin/webp8.phar"

? Checking Composer compatibility
    > Supported version detected
? No compactor to register
? Adding main file: K:/dev/github/php-webp8/src/EntryPoint.php
? Adding requirements checker
? Adding binary files
    > No file found
? Auto-discover files? No
? Exclude dev files? No
? Adding files
    > 250 file(s)
? Generating new stub
  - Using shebang line: #!/usr/bin/env php
  - Using banner:
    > Generated by Humbug Box 4.6.10@6dc6a13.
    >
    > @link https://github.com/humbug/box
? Dumping the Composer autoloader

In Filesystem.php line 117:

  Failed to remove directory "C:\Users\Kokosik\AppData\Local\Temp\box\Box91332": rmdir(C:\Users\Kokosik\App
  Data\Local\Temp\box\Box91332): Resource temporarily unavailable


compile [--debug] [--no-parallel] [--sort-compiled-files] [--no-restart] [--dev] [--no-config] [--with-docker]
 [--composer-bin COMPOSER-BIN] [--allow-composer-check-failure] [-c|--config CONFIG] [-d|--working-dir WORKING
-DIR]
box.json.dist
{
   "directories": [
       "src/",
       "vendor/"
   ],
   "main": "src/EntryPoint.php",
   "output": "bin/webp8.phar",
   "compression": "GZ",
   "stub": true,
   "exclude-dev-files": false
}

It's this PR that causing the problem: #1538

Here's a sample code that reproduces the problem on Windows:

use Fidry\FileSystem\FS;

require_once __DIR__ . '/vendor/autoload.php';

$cwd = __DIR__;

$tmp = FS::makeTmpDir('box', 'test');
chdir($tmp);

// throws PHP Fatal error:  Uncaught Symfony\Component\Filesystem\Exception\IOException: Failed to remove directory "C:\Users\Kokosik\AppData\Local\Temp\box\test63822": rmdir(C:\Users\Kokosik\AppData\Local\Temp\box\test63822): Resource temporarily unavailable in K:\dev\github\php-sandbox\vendor\symfony\filesystem\Filesystem.php:194
FS::remove($tmp);

chdir($cwd);

The problem started when the chdir($cwd); was moved below FS::remove($tmp);. The delete of the current working directory behavior is different between Windows and Linux based systems. Windows doesn't allow it while Linux based system do allow it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions