ramsey / composer-install

:gift: A GitHub Action to streamline installation of PHP dependencies with Composer.
MIT License
230 stars 33 forks source link

Action randomly fail on windows #79

Closed LastDragon-ru closed 2 years ago

LastDragon-ru commented 3 years ago

Action: https://github.com/LastDragon-ru/lara-asp/blob/f990092be38daceb9e7323ccd7683c8d92c974a3/.github/workflows/phpunit.yml

image image

Run ramsey/composer-install@v1
  with:
    dependency-versions: lowest
Composer cache directory found at C:/Users/runneradmin/AppData/Local/Composer
Using lowest versions of dependencies
PHP version is 8.0.1
Cache primary key is php-8.0.1-lowest-d4af0aef979962d8b86c4245098c594c33b9a95fe0dcd010d691cccf5d6c37b8-
Cache restore keys are: php-8.0.1-lowest-d4af0aef979962d8b86c4245098c594c33b9a95fe0dcd010d691cccf5d6c37b8-, php-8.0.1-lowest-
C:\windows\system32\cmd.exe /D /S /C "c:\tools\php\composer.bat update --prefer-lowest --no-interaction --no-progress --ansi"
Loading composer repositories with package information
Received 9916529 of 9916529 (100.0%), 54.0 MBs/sec
Cache Size: ~9 MB (9916529 B)
C:\windows\System32\tar.exe -z -xf D:/a/_temp/42b8fabb-41d9-442b-a36d-352b47888967/cache.tgz -P -C D:/a/lara-asp-eloquent/lara-asp-eloquent
Error: file_get_contents(C:/Users/runneradmin/AppData/Local/Composer/repo/https---repo.packagist.org/provider-symfony~console.json): Failed to open stream: Resource temporarily unavailable

  [ErrorException]                                                                                                     
  file_get_contents(C:/Users/runneradmin/AppData/Local/Composer/repo/https---repo.packagist.org/provider-symfony~cons  
  ole.json): Failed to open stream: Resource temporarily unavailable                                                   

update [--with WITH] [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-install] [--no-autoloader] [--no-scripts] [--no-suggest] [--no-progress] [-w|--with-dependencies] [-W|--with-all-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>]...

Error: The process 'c:\tools\php\composer.bat' failed with exit code 1
Cache restored from key: php-8.0.1-lowest-d4af0aef979962d8b86c4245098c594c33b9a95fe0dcd010d691cccf5d6c37b8-
ctrl-f5 commented 3 years ago

Can confirm, also experiencing this issue randomly in the PR https://github.com/pact-foundation/pact-php/pull/194

ramsey commented 3 years ago

A recent change might have fixed this or at least made it less likely to occur: https://github.com/ramsey/composer-install/commit/370d5215a48e6be6b64ca66128d0cafdbf1d3854

Please keep trying it out and let me know if you see these errors again.

My hypothesis right now is that, since the cache keys were the same across operating systems, if (for example) the job for Windows tried to run with PHP 7.4 and lowest dependencies at the same time as the job for Linux with PHP 7.4 and lowest dependencies, then maybe there was some kind of read-access blocking to the device, since I assume it's sharing the same mounted filesystem for the caches.

Anyway, I have no confirmation this has fixed it, but I haven't seen the issue since I made this change.

ramsey commented 3 years ago

I just got a failure on Windows in another repo: https://github.com/ramsey/php-library-starter-kit/runs/2070621484

Error: file_get_contents(C:/Users/runneradmin/AppData/Local/Composer/repo/https---repo.packagist.org/provider-phpunit~phpunit.json): Failed to open stream: Resource temporarily unavailable
ramsey commented 3 years ago

Another error in a different repo. Different error, but I think it's the same root cause. https://github.com/ramsey/devtools-lib/runs/2078491516?check_suite_focus=true

Error: rename(C:/Users/runneradmin/AppData/Local/Composer/repo/https---repo.packagist.org/provider-slevomat~coding-standard.json.6048eddc87a296.29835153.tmp,C:/Users/runneradmin/AppData/Local/Composer/repo/https---repo.packagist.org/provider-slevomat~coding-standard.json): Access is denied (code: 5)
ramsey commented 3 years ago

Yet another in a different repo. This is the "access is denied" error: https://github.com/ramsey/conventional-commits/runs/2108197091?check_suite_focus=true

LastDragon-ru commented 3 years ago

I haven't seen the issue since I made this change.

https://github.com/LastDragon-ru/lara-asp-formatter/runs/2108870196?check_suite_focus=true

but seems it occurs less than before

LastDragon-ru commented 3 years ago

Also another error:

image

Run ramsey/composer-install@v1
  with:
    dependency-versions: highest
Composer cache directory found at C:/Users/runneradmin/AppData/Local/Composer
Composer working directory set to project root.
Using highest versions of dependencies
PHP version is 8.0.3
Operating system is win32
Cache primary key is win32-php-8.0.3-highest-fd4cda7bf11267d674976d6c8660bb91b36447fe6a1624d907b9b88fdb8fc218-
Cache restore keys are: win32-php-8.0.3-highest-fd4cda7bf11267d674976d6c8660bb91b36447fe6a1624d907b9b88fdb8fc218-, win32-php-8.0.3-highest-
C:\Windows\system32\cmd.exe /D /S /C "c:\tools\php\composer.bat update --no-interaction --no-progress --ansi"
Loading composer repositories with package information
Received 19109288 of 19109288 (100.0%), 67.2 MBs/sec
Cache Size: ~18 MB (19109288 B)
C:\Windows\System32\tar.exe -z -xf D:/a/_temp/edd2f068-d936-4fe2-b234-ec2344fed194/cache.tgz -P -C D:/a/lara-asp-core/lara-asp-core
Cache restored successfully
Cache restored from key: win32-php-8.0.3-highest-fd4cda7bf11267d674976d6c8660bb91b36447fe6a1624d907b9b88fdb8fc218-
Error: rename(C:/Users/runneradmin/AppData/Local/Composer/repo/https---repo.packagist.org/provider-dragonmantank~cron-expression.json.60613c1c3c6c05.64268794.tmp,C:/Users/runneradmin/AppData/Local/Composer/repo/https---repo.packagist.org/provider-dragonmantank~cron-expression.json): Access is denied (code: 5)

  [ErrorException]                                                                                                     
  rename(C:/Users/runneradmin/AppData/Local/Composer/repo/https---repo.packagist.org/provider-dragonmantank~cron-expr  
  ession.json.60613c1c3c6c05.64268794.tmp,C:/Users/runneradmin/AppData/Local/Composer/repo/https---repo.packagist.org  
  /provider-dragonmantank~cron-expression.json): Access is denied (code: 5)                                            

update [--with WITH] [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--lock] [--no-install] [--no-autoloader] [--no-scripts] [--no-suggest] [--no-progress] [-w|--with-dependencies] [-W|--with-all-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>]...

Error: The process 'c:\tools\php\composer.bat' failed with exit code 1
jaapio commented 3 years ago

I can confirm this issue is still there. we do have the same issue in https://github.com/phpDocumentor/phpDocumentor

jaapio commented 3 years ago
 Operating system is win32
Cache primary key is win32-php-7.2.34-locked-0b124dbf7c8e0b4aecdd9c1cc21fb55002ef6c6e082968ff7ac63b2722b2fc37---optimize-autoloader
Cache restore keys are: win32-php-7.2.34-locked-0b124dbf7c8e0b4aecdd9c1cc21fb55002ef6c6e082968ff7ac63b2722b2fc37-, win32-php-7.2.34-locked-
C:\Windows\system32\cmd.exe /D /S /C "c:\tools\php\composer.bat install --no-interaction --no-progress --ansi --optimize-autoloader"
Received 14696183 of 14696183 (100.0%), 62.8 MBs/sec
Cache Size: ~14 MB (14696183 B)
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
C:\Windows\System32\tar.exe -z -xf D:/a/_temp/f161ff02-06b2-40a1-9215-646e7cb536af/cache.tgz -P -C D:/a/phpDocumentor/phpDocumentor
Package operations: 65 installs, 0 updates, 0 removals
  - Downloading symfony/flex (v1.13.3)
  - Downloading doctrine/event-manager (1.1.1)
  - Downloading doctrine/lexer (1.2.1)
  - Downloading fzaninotto/faker (v1.9.2)
  - Downloading jawira/plantuml (v1.59.0)
  - Downloading jean85/pretty-package-versions (2.0.4)
  - Downloading league/commonmark (1.6.6)
  - Downloading league/mime-type-detection (1.7.0)
  - Downloading league/pipeline (1.0.0)
  - Downloading symfony/polyfill-ctype (v1.23.0)
  - Downloading psr/event-dispatcher (1.0.0)
  - Downloading psr/container (1.1.1)
  - Downloading psr/cache (1.0.1)
  - Downloading symfony/contracts (v2.4.0)
  - Downloading psr/log (1.1.4)
  - Downloading league/tactician (v1.1.0)
  - Downloading league/tactician-logger (v0.10.0)
  - Downloading league/tactician-container (2.0.0)
  - Downloading league/tactician-bundle (v1.2.0)
  - Downloading league/uri-interfaces (2.2.0)
  - Downloading league/uri (6.3.0)
  - Downloading mikey179/vfsstream (v1.6.9)
  - Downloading hamcrest/hamcrest-php (v2.0.1)
  - Downloading mockery/mockery (1.3.4)
  - Downloading league/flysystem (1.1.4)
  - Downloading phpdocumentor/flyfinder (1.1.0)
  - Downloading phpdocumentor/graphviz (2.0.0)
  - Downloading nikic/php-parser (v4.12.0)
Cache restored successfully
Cache restored from key: win32-php-7.2.34-locked-0b124dbf7c8e0b4aecdd9c1cc21fb55002ef6c6e082968ff7ac63b2722b2fc37---optimize-autoloader
Error: copy(C:/Users/runneradmin/AppData/Local/Composer/files/phpdocumentor/reflection/d02003861304bd11c7a7c8649c2f9b9603d88cb7.zip): failed to open stream: Resource temporarily unavailable

If you look at the order of the restore messages this seems to be odd...

Linux does this:

 Operating system is linux
Cache primary key is linux-php-8.0.9-locked-f6b45f088bb279953b0c03505a981d2bb4f232fd97a0cc6b7dd29dfddc41e81b---optimize-autoloader
Cache restore keys are: linux-php-8.0.9-locked-f6b45f088bb279953b0c03505a981d2bb4f232fd97a0cc6b7dd29dfddc41e81b-, linux-php-8.0.9-locked-
/usr/local/bin/composer install --no-interaction --no-progress --ansi --optimize-autoloader
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Received 14639000 of 14639000 (100.0%), 69.5 MBs/sec
Cache Size: ~14 MB (14639000 B)
/usr/bin/tar --use-compress-program zstd -d -xf /home/runner/work/_temp/c3d4442d-5a9f-4f74-8aa5-8a3ee769e186/cache.tzst -P -C /home/runner/work/phpDocumentor/phpDocumentor
Cache restored successfully
Cache restored from key: linux-php-8.0.9-locked-f6b45f088bb279953b0c03505a981d2bb4f232fd97a0cc6b7dd29dfddc41e81b---optimize-autoloader
Package operations: 65 installs, 0 updates, 0 removals
  - Installing symfony/flex (v1.13.3): Extracting archive
  - Installing doctrine/event-manager (1.1.1): Extracting archive
  - Installing doctrine/lexer (1.2.1): Extracting archive

it looks like the cache restore is taking to long on windows, and it continues before it was fully restored?

mvriel commented 3 years ago

The issue still occurs (https://github.com/phpDocumentor/phpDocumentor/runs/3630487891?check_suite_focus=true); maybe something as simple as a retry option would be useful? This could also help in cases of flaky networks when downloading/installing composer packages

ramsey commented 2 years ago

This is fixed in v2, please upgrade using ramsey/composer-install@v2 or ramsey/composer-install@2.0.0. Details are available on the release announcement and the README.

Thanks!