cweagans / composer-patches

Simple patches plugin for Composer
https://www.cweagans.net/project/composer-patches
BSD 3-Clause "New" or "Revised" License
1.52k stars 240 forks source link

composer install does... nothing :( #355

Closed giulioprovasi closed 1 year ago

giulioprovasi commented 3 years ago

I have followed the documentation, added the following to my composer.json

    "extra": {
        "enable-patching": true,
        "composer-exit-on-patch-failure": true,
        "patches": {
            "laravel/horizon": {
                "Don't use asset() helper for horizon, url() instead": "./patches/laravel/horizon/drop_asset_helper.patch"
            }
        }
    },

And my patch located at the right place.

I then rm -rf vendor and composer install but no patches are applied.

In order for a patch to be ran I MUST run composer update, which I don't want (I am building a docker image) :

FROM composer:${COMPOSER_VERSION} as composer
COPY composer.json ./
COPY composer.lock ./
COPY patches/ ./patches/
RUN composer install \
        --ignore-platform-reqs \
        --no-autoloader \
        --no-dev \
        --no-interaction \
        --no-scripts \
        --no-suggest \
        --no-progress \
    ; \
    find vendor -name ".git" -type d | xargs rm -rf

Any ideas ?

cweagans commented 3 years ago

Can you please provide your composer.json?

giulioprovasi commented 3 years ago

sure here it is

{
    "name": "acme/app",
    "type": "library",
    "description": "app",
    "keywords": [
        "laravel",
        "site",
    ],
    "license": "proprietary",
    "authors": [
        {
            "name": "acme",
            "email": "dev@acme.com",
            "homepage": "https://www.acme.com/"
        }
    ],
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.dev.acme.com"
        }
    ],
    "require": {
        "php": ">=7.4.0",
        "ext-bcmath": "*",
        "ext-curl": "*",
        "ext-dom": "*",
        "ext-fileinfo": "*",
        "ext-gd": "*",
        "ext-gmp": "*",
        "ext-hash": "*",
        "ext-iconv": "*",
        "ext-imagick": "*",
        "ext-json": "*",
        "ext-mbstring": "*",
        "ext-pdo_mysql": "*",
        "ext-pdo_sqlite": "*",
        "ext-posix": "*",
        "bschmitt/laravel-amqp": "^2.0",
        "chadsikorra/php-simple-enum": "^1.0",
        "composer/composer": "^1.10",
        "cweagans/composer-patches": "^1.7",
        "doctrine/dbal": "^2.9",
        "elasticsearch/elasticsearch": "^7.0",
        "fico7489/laravel-pivot": "^3.0",
        "fideloper/proxy": "^4.0",
        "fruitcake/laravel-cors": "^1.0",
        "gabrielelana/byte-units": "^0.5",
        "geoip2/geoip2": "^2.9",
        "guzzlehttp/guzzle": "^6.3",
        "iatstuti/laravel-cascade-soft-deletes": "^3.0",
        "acme/api": "^3.0",
        "acme/laravel-auth": "^3.0",
        "acme/laravel-client-api": "~3.6",
        "acme/laravel-filesystem": "dev-master",
        "acme/laravel-oauth2": "^2.2",
        "acme/laravel-rabbitmq-bundle": "dev-master",
        "acme/lib-laravel-configurator": "^1.0",
        "acme/lib-laravel-model-cache": "^1.0",
        "acme/lib-shop-core": "^0.4",
        "acme/lib-site-api-helper": "^3.0",
        "acme/shared": "dev-master",
        "intervention/image": "^2.4",
        "kalnoy/nestedset": "^5.0",
        "laravel/framework": "^7.17.1",
        "laravel/horizon": "^4.3",
        "laravel/tinker": "^2.3",
        "league/flysystem-aws-s3-v3": "^1.0",
        "mantas-done/subtitles": "^0.3.7",
        "norkunas/youtube-dl-php": "^1.6",
        "opis/closure": "^3.3",
        "php-ffmpeg/php-ffmpeg": "dev-acme-master",
        "predis/predis": "^1.1",
        "rlanvin/php-ip": "1.*",
        "rutorika/sortable": "^4.7",
        "spatie/laravel-csp": "^2.6",
        "staudenmeir/eloquent-has-many-deep": "^1.12",
        "staudenmeir/eloquent-json-relations": "^1.1",
        "stephenhill/base58": "^1.1",
        "swagger-api/swagger-ui": "^3.22",
        "symfony/serializer": "^4.3",
        "tymon/jwt-auth": "dev-develop",
        "watson/validating": "^3.2",
        "whichbrowser/parser": "^2.0",
        "zircote/swagger-php": "^3.0"
    },
    "require-dev": {
        "barryvdh/laravel-debugbar": "^3.2",
        "barryvdh/laravel-ide-helper": "dev-master",
        "beyondcode/laravel-dump-server": "^1.2",
        "filp/whoops": "^2.0",
        "fzaninotto/faker": "^1.4",
        "mockery/mockery": "^1.0",
        "nunomaduro/collision": "^4.0",
        "phpunit/phpunit": "^7.5"
    },
    "suggest": {
        "ext-pdo_mysql": "Allows connecting to a MySQL database"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": "dist",
        "sort-packages": true
    },
    "extra": {
        "laravel": {
            "dont-discover": []
        },
        "enable-patching": false,
        "patches": {
            "laravel/horizon": {
                "Don't use asset() helper for horizon, url() instead": "./patches/laravel/horizon/drop_asset_helper.patch"
            }
        }
    },
    "autoload": {
        "classmap": [
            "database/seeds",
            "database/factories"
        ],
        "psr-4": {
            "App\\": "app/",
            "AppSeeds\\": "database/seeds/",
            "Domain\\": "domain/",
            "Illuminate\\": "monkeys/laravel/framework/src/Illuminate/"
        },
        "files": [
            "app/Support/helpers.php"
        ]
    },
    "autoload-dev": {
        "psr-4": {
            "Tests\\": "tests/"
        }
    },
    "minimum-stability": "dev",
    "prefer-stable": true
}
giulioprovasi commented 3 years ago

I ended up doing same stuff as predis/predis in the meantime :

composer.json

"scripts": {
        "post-install-cmd": "./scripts/apply-patches.sh",
        "post-update-cmd": "./scripts/apply-patches.sh"
    }

apply-patches.sh

#!/usr/bin/env bash

# hop in current script dir
cd "$(dirname "$(readlink -f "$BASH_SOURCE")")"

pushd ../patches >/dev/null

for patch in $(find . -type f -name "*.patch"); do
  path=${patch%/*}
  echo "Patching vendor/${path#*/}"
  patch -p1 --forward --no-backup-if-mismatch -r - -d "../vendor/${path}" <"$patch"
done

popd >/dev/null
ireznik commented 3 years ago

Can you try and remove the following line: "preferred-install": "source" That was causing my broken composer install run

kayue commented 3 years ago

I think you have to remove the --no-scripts option.

soullivaneuh commented 3 years ago

Got the same behavior. Is the "preferred-install": "source" a mandatory option?

Because installing all dependence at source is much more longer than the dist method.

tobiasbaehr commented 3 years ago

@soullivaneuh No, dist works also. But with composer 2.1.x dist is the default value, also for dev dependencies. https://github.com/composer/composer/pull/9603

snipiba commented 1 year ago

I got same issue... added all from documentation and composer install does nothing after installing all packages from composer.json... missing something? or this need to run composer install twice to get results? all screenshots from documentation shows that results is after composer update not "install". ...

cweagans commented 1 year ago

Got the same behavior. Is the "preferred-install": "source" a mandatory option?

Not mandatory, but significantly increases the chances that a patch will apply.

Closing this -- main works a lot differently now.

arderyp commented 4 months ago

This is closed as complete but I don't see a solution. I am having the same problem to this day on latest everything.

The scenario is that I am deploying to Pantheon, a popular hosting service.

My Pantheon and local are on the latest version of all dependencies and are in sync.

I then introduce a new patch on my local. It works if I delete the composer/vendor package directory, then run composer update. It reinstalls and applies the patch. Likewise, "composer patches-repatch" works.

But Pantheon doesn't do this. They run "composer --no-interaction --no-progress --prefer-dist --ansi install". The output of this command suggests there is nothing to update or install. The latching mechanism isn't triggered at all.

Am I missing something @cweagans?

cweagans commented 4 months ago

Please open a new issue and provide all the details about your project.

arderyp commented 4 months ago

@cweagans done #583