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

composer install does... nothing :( #355

Closed
giulioprovasi opened this issue Feb 18, 2021 · 12 comments
Closed

composer install does... nothing :( #355

giulioprovasi opened this issue Feb 18, 2021 · 12 comments

Comments

@giulioprovasi
Copy link

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
Copy link
Owner

Can you please provide your composer.json?

@giulioprovasi
Copy link
Author

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
Copy link
Author

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
Copy link

ireznik commented Feb 24, 2021

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

@kayue
Copy link

kayue commented Feb 26, 2021

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

@soullivaneuh
Copy link

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
Copy link

@soullivaneuh No, dist works also. But with composer 2.1.x dist is the default value, also for dev dependencies. composer/composer#9603

@snipiba
Copy link

snipiba commented Oct 26, 2022

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
Copy link
Owner

cweagans commented Feb 7, 2023

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 cweagans closed this as completed Feb 7, 2023
@arderyp
Copy link

arderyp commented Jun 19, 2024

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
Copy link
Owner

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

@arderyp
Copy link

arderyp commented Jun 19, 2024

@cweagans done #583

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants