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

Error applying php-parser patch on rector-src with Mac #8143

Closed
beberlei opened this issue Aug 17, 2023 · 7 comments
Closed

Error applying php-parser patch on rector-src with Mac #8143

beberlei opened this issue Aug 17, 2023 · 7 comments

Comments

@beberlei
Copy link

Bug Report

Subject Details
Rector version main 5363a676265cbe868f4ecc6bde8c6a99b213d028

composer install fails after checking out, with a Mac on PHP 8.1

be> ~/tideways/workspace/rector-src (main)% composer install
Gathering patches for root package.
Removing package illuminate/container so that it can be re-installed and re-patched.
  - Removing illuminate/container (v10.19.0)
Removing package nikic/php-parser so that it can be re-installed and re-patched.
  - Removing nikic/php-parser (v4.17.1)
Installing dependencies from lock file (including require-dev)
Verifying lock file contents can be installed on current platform.
Package operations: 2 installs, 0 updates, 0 removals
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
  - Installing nikic/php-parser (v4.17.1): Extracting archive
  - Installing illuminate/container (v10.19.0): Extracting archive
  - Applying patches for nikic/php-parser
    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-expr-closure-php.patch (0)


    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-finally-php.patch (1)








   Could not apply patch! Skipping. The error was: Cannot apply patch https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-finally-php.patch

In Patches.php line 331:

  Cannot apply patch 1 (https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-finally-php.patch)!


install [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--dev] [--no-suggest] [--no-dev] [--no-autoloader] [--no-progress] [--no-install] [-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] [--] [<packages>...]
@beberlei beberlei added the bug label Aug 17, 2023
@samsonasik
Copy link
Member

I can't reproduce, did you try remove vendor first?

rm -rf vendor
composer clear-cache
composer up

@Herz3h
Copy link

Herz3h commented Aug 21, 2023

Same issue here, mac m2, php 8.1:

Did try:

rm -rf vendor
composer clear-cache
composer up
 Cannot apply patch 1 (https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-finally-php.patch)!

Also, I don't see patch prompts with composer update only, I run it with -v to see the prompts. Here is the output, by just pressing Enter to every prompt:

image

Have tried applying that patch manually with git version 2.39.2 (Apple Git-143) and I get the same exact error. No clue why...

@samsonasik
Copy link
Member

not sure, I am using mac m1, working ok on my side:

➜  rector-src git:(main) git -v
git version 2.37.1 (Apple Git-137.1)

➜  rector-src git:(main) rm -rf vendor

➜  rector-src git:(main) composer up 
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Lock file operations: 4 installs, 0 updates, 0 removals
  - Locking filp/whoops (2.15.3)
  - Locking nunomaduro/collision (v7.8.1)
  - Locking nunomaduro/termwind (v1.15.1)
  - Locking robiningelbrecht/phpunit-pretty-print (v1.2.2)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 93 installs, 0 updates, 0 removals
  - Downloading rector/extension-installer (0.11.2)
  - Downloading cweagans/composer-patches (1.7.3)
  - Downloading filp/whoops (2.15.3)
  - Downloading psr/simple-cache (3.0.0)
  - Downloading nategood/httpful (0.3.2)
  - Downloading nunomaduro/termwind (v1.15.1)
  - Downloading ondram/ci-detector (4.1.0)
  - Downloading phpstan/phpstan-php-parser (1.1.0)
  - Downloading phpstan/phpstan-strict-rules (1.5.1)
  - Downloading sebastian/version (4.0.1)
  - Downloading sebastian/lines-of-code (2.0.0)
  - Downloading sebastian/environment (6.0.1)
  - Downloading sebastian/complexity (3.0.0)
  - Downloading sebastian/code-unit-reverse-lookup (3.0.0)
  - Downloading phpunit/php-text-template (3.0.0)
  - Downloading phpunit/php-file-iterator (4.0.2)
  - Downloading phpunit/php-invoker (4.0.0)
  - Downloading phpunit/php-timer (6.0.0)
  - Downloading react/dns (v1.11.0)
  - Downloading sebastian/type (4.0.0)
  - Downloading sebastian/recursion-context (5.0.0)
  - Downloading sebastian/object-reflector (3.0.0)
  - Downloading sebastian/object-enumerator (5.0.0)
  - Downloading sebastian/exporter (5.0.0)
  - Downloading sebastian/diff (5.0.3)
  - Downloading sebastian/code-unit (2.0.0)
  - Downloading sebastian/cli-parser (2.0.0)
  - Downloading nunomaduro/collision (v7.8.1)
  - Downloading robiningelbrecht/phpunit-pretty-print (v1.2.2)
  - Downloading spatie/enum (3.13.0)
  - Downloading react/socket (v1.13.0)
  - Downloading symplify/rule-doc-generator-contracts (11.1.26)
  - Downloading nette/robot-loader (v3.4.2)
  - Downloading tomasvotruba/cognitive-complexity (0.1.1)
  - Downloading tomasvotruba/type-coverage (0.2.0)
  - Installing rector/extension-installer (0.11.2): Extracting archive
  - Installing cweagans/composer-patches (1.7.3): Extracting archive
Gathering patches for root package.
Gathering patches for dependencies. This might take a minute.
  - Installing phpstan/phpstan (1.10.29): Extracting archive
  - Installing phpstan/extension-installer (1.3.1): Extracting archive
  - Installing composer/semver (3.3.2): Extracting archive
  - Installing psr/log (3.0.0): Extracting archive
  - Installing composer/pcre (3.1.0): Extracting archive
  - Installing composer/xdebug-handler (3.0.3): Extracting archive
  - Installing doctrine/inflector (2.0.8): Extracting archive
  - Installing filp/whoops (2.15.3): Extracting archive
  - Installing psr/simple-cache (3.0.0): Extracting archive
  - Installing psr/container (2.0.2): Extracting archive
  - Installing illuminate/contracts (v10.19.0): Extracting archive
  - Installing myclabs/deep-copy (1.11.1): Extracting archive
  - Installing nategood/httpful (0.3.2): Extracting archive
  - Installing nette/utils (v3.2.10): Extracting archive
  - Installing nette/finder (v2.6.0): Extracting archive
  - Installing symfony/service-contracts (v3.3.0): Extracting archive
  - Installing symfony/polyfill-mbstring (v1.27.0): Extracting archive
  - Installing symfony/console (v6.3.2): Extracting archive
  - Installing nunomaduro/termwind (v1.15.1): Extracting archive
  - Installing ondram/ci-detector (4.1.0): Extracting archive
  - Installing phar-io/version (3.2.1): Extracting archive
  - Installing phar-io/manifest (2.0.3): Extracting archive
  - Installing phpstan/phpdoc-parser (1.23.1): Extracting archive
  - Installing phpstan/phpstan-deprecation-rules (1.1.4): Extracting archive
  - Installing phpstan/phpstan-php-parser (1.1.0): Extracting archive
  - Installing phpstan/phpstan-phpunit (1.3.13): Extracting archive
  - Installing phpstan/phpstan-strict-rules (1.5.1): Extracting archive
  - Installing phpstan/phpstan-webmozart-assert (1.2.4): Extracting archive
  - Installing theseer/tokenizer (1.2.1): Extracting archive
  - Installing sebastian/version (4.0.1): Extracting archive
  - Installing nikic/php-parser (v4.17.1): Extracting archive
  - Installing sebastian/lines-of-code (2.0.0): Extracting archive
  - Installing sebastian/environment (6.0.1): Extracting archive
  - Installing sebastian/complexity (3.0.0): Extracting archive
  - Installing sebastian/code-unit-reverse-lookup (3.0.0): Extracting archive
  - Installing phpunit/php-text-template (3.0.0): Extracting archive
  - Installing phpunit/php-file-iterator (4.0.2): Extracting archive
  - Installing phpunit/php-code-coverage (10.1.3): Extracting archive
  - Installing phpunit/php-invoker (4.0.0): Extracting archive
  - Installing phpunit/php-timer (6.0.0): Extracting archive
  - Installing react/promise (v2.10.0): Extracting archive
  - Installing react/event-loop (v1.4.0): Extracting archive
  - Installing react/cache (v1.2.0): Extracting archive
  - Installing react/dns (v1.11.0): Extracting archive
  - Installing evenement/evenement (v3.0.2): Extracting archive
  - Installing react/stream (v1.3.0): Extracting archive
  - Installing webmozart/assert (1.11.0): Extracting archive
  - Installing rector/phpstan-rules (0.6.11): Extracting archive
  - Installing rector/rector-doctrine (dev-main c0ab738): Extracting archive
  - Installing rector/rector-downgrade-php (dev-main ae6d18d): Extracting archive
  - Installing symfony/finder (v6.3.3): Extracting archive
  - Installing symfony/filesystem (v6.3.1): Extracting archive
  - Installing illuminate/container (v10.19.0): Extracting archive
  - Installing rector/rector-generator (dev-main 234037c): Extracting archive
  - Installing rector/rector-phpunit (dev-main e6dd6a0): Extracting archive
  - Installing rector/rector-symfony (dev-main ef9424a): Extracting archive
  - Installing sebastian/type (4.0.0): Extracting archive
  - Installing sebastian/recursion-context (5.0.0): Extracting archive
  - Installing sebastian/object-reflector (3.0.0): Extracting archive
  - Installing sebastian/object-enumerator (5.0.0): Extracting archive
  - Installing sebastian/global-state (6.0.1): Extracting archive
  - Installing sebastian/exporter (5.0.0): Extracting archive
  - Installing sebastian/diff (5.0.3): Extracting archive
  - Installing sebastian/comparator (5.0.1): Extracting archive
  - Installing sebastian/code-unit (2.0.0): Extracting archive
  - Installing sebastian/cli-parser (2.0.0): Extracting archive
  - Installing phpunit/phpunit (10.3.2): Extracting archive
  - Installing nunomaduro/collision (v7.8.1): Extracting archive
  - Installing robiningelbrecht/phpunit-pretty-print (v1.2.2): Extracting archive
  - Installing spatie/enum (3.13.0): Extracting archive
  - Installing symfony/process (v6.3.2): Extracting archive
  - Installing symplify/easy-ci (11.3.1.72): Extracting archive
  - Installing symplify/easy-coding-standard (12.0.6): Extracting archive
  - Installing react/socket (v1.13.0): Extracting archive
  - Installing react/child-process (v0.6.5): Extracting archive
  - Installing fidry/cpu-core-counter (0.5.1): Extracting archive
  - Installing clue/ndjson-react (v1.3.0): Extracting archive
  - Installing symplify/easy-parallel (11.1.27): Extracting archive
  - Installing symplify/phpstan-extensions (11.3.0): Extracting archive
  - Installing symplify/phpstan-rules (12.1.4.72): Extracting archive
  - Installing symplify/rule-doc-generator-contracts (11.1.26): Extracting archive
  - Installing symfony/yaml (v6.3.3): Extracting archive
  - Installing nette/robot-loader (v3.4.2): Extracting archive
  - Installing symplify/rule-doc-generator (12.0.2): Extracting archive
  - Installing symplify/vendor-patches (11.2.3): Extracting archive
  - Installing tomasvotruba/class-leak (0.1.1.72): Extracting archive
  - Installing tomasvotruba/cognitive-complexity (0.1.1): Extracting archive
  - Installing tomasvotruba/lines (0.3.1.72): Extracting archive
  - Installing tomasvotruba/type-coverage (0.2.0): Extracting archive
  - Installing tomasvotruba/unused-public (0.2.0): Extracting archive
  - Installing tracy/tracy (v2.10.3): Extracting archive
  - Applying patches for symfony/console
    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/symfony-console-helper-helper-php.patch (0)

  - Applying patches for nikic/php-parser
    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-expr-closure-php.patch (0)
    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-finally-php.patch (1)
    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-function-php.patch (2)
    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-do-php.patch (3)
    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-catch-php.patch (4)
    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-trycatch-php.patch (5)
    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-for-php.patch (6)
    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-classmethod-php.patch (7)
    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-else-php.patch (8)
    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-while-php.patch (9)
    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-foreach-php.patch (10)
    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-if-php.patch (11)
    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-case-php.patch (12)
    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-elseif-php.patch (13)
    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches/nikic-php-parser-lib-phpparser-node-stmt-namespace-php.patch (14)

  - Applying patches for illuminate/container
    https://raw.githubusercontent.com/rectorphp/vendor-patches/main/patches//illuminate-container-container-php.patch (0)

2 package suggestions were added by new dependencies, use `composer suggest` to see details.
Generating autoload files
62 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
rector/rector-installer: Extensions installed
> rector/rector-doctrine: installed
> rector/rector-downgrade-php: installed
> rector/rector-generator: installed
> rector/rector-phpunit: installed
> rector/rector-symfony: installed
phpstan/extension-installer: Extensions installed
> phpstan/phpstan-deprecation-rules: installed
> phpstan/phpstan-php-parser: installed
> phpstan/phpstan-phpunit: installed
> phpstan/phpstan-strict-rules: installed
> phpstan/phpstan-webmozart-assert: installed
> rector/phpstan-rules: installed
> symplify/phpstan-extensions: installed
> symplify/phpstan-rules: installed
> tomasvotruba/cognitive-complexity: installed
> tomasvotruba/type-coverage: installed
> tomasvotruba/unused-public: installed
No security vulnerability advisories found

@Herz3h
Copy link

Herz3h commented Aug 21, 2023

Very strange error, I have tried downloading the patch locally to apply it, and if I remove 1 hunk out of 2 (either one removed) it applies patch, but not when I have 2 hunks in the patch, unsure what could be the reason. Not really familiar with git patches syntax

I'll try to downgrade git to v2.37.1

Edit: It seems that the problem is with the patch executable (nothing to do with git-patch). I had this version:

patch 2.0-12u11-Apple

I installed gpatch (had to add package directory to PATH) and it now works without an issue.

@samsonasik
Copy link
Member

samsonasik commented Aug 21, 2023

@Herz3h thank you for investigation, I think that's worth a documentation update, could you provide readme update PR on

https://github.com/rectorphp/rector-src/blob/main/README.md

thank you.

@staabm
Copy link
Contributor

staabm commented Aug 21, 2023

I remember having the same problem on my mac. IIRC installing a newer version of gpatch is the way to fix it.

its a global macos problem which came with one of the newer macos major updates, not rector specific


update: I found my own problem which links cweagans/composer-patches#423 with a in-deep analysis of the cause

@beberlei
Copy link
Author

Indeed, brew install gpatch fixes the issue.

@beberlei beberlei closed this as not planned Won't fix, can't repro, duplicate, stale Aug 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants