composer-patches icon indicating copy to clipboard operation
composer-patches copied to clipboard

composer install does... nothing :(

Open giulioprovasi opened this issue 4 years ago • 7 comments
trafficstars

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 ?

giulioprovasi avatar Feb 18 '21 10:02 giulioprovasi

Can you please provide your composer.json?

cweagans avatar Feb 18 '21 18:02 cweagans

sure here it is

{
    "name": "acme/app",
    "type": "library",
    "description": "app",
    "keywords": [
        "laravel",
        "site",
    ],
    "license": "proprietary",
    "authors": [
        {
            "name": "acme",
            "email": "[email protected]",
            "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 avatar Feb 19 '21 13:02 giulioprovasi

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

giulioprovasi avatar Feb 19 '21 13:02 giulioprovasi

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

ireznik avatar Feb 24 '21 07:02 ireznik

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

kayue avatar Feb 26 '21 17:02 kayue

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.

soullivaneuh avatar Apr 21 '21 13:04 soullivaneuh

@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

tobiasbaehr avatar Jun 04 '21 09:06 tobiasbaehr

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". ...

snipiba avatar Oct 26 '22 16:10 snipiba

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.

cweagans avatar Feb 07 '23 21:02 cweagans