2

I can not require the following package in a contao project.

$ php composer.phar require -v con4gis/con4gis_forum
Using version ^1.7 for con4gis/con4gis_forum
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Dependency resolution completed in 0.026 seconds
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: don't install con4gis/con4gis_forum v1.7.1
    - Installation request for con4gis/con4gis_forum ^1.7 -> satisfiable by con4gis/con4gis_forum[v1.7.0, v1.7.1].
    - con4gis/con4gis_forum v1.7.0 requires con4gis/con4gis_core ~1.7 -> satisfiable by con4gis/con4gis_core[v1.7.0, v1.7.1].
    - con4gis/con4gis_core v1.7.0 requires menatwork/contao-multicolumnwizard 3.3.8 -> satisfiable by menatwork/contao-multicolumnwizard[3.3.8].
    - con4gis/con4gis_core v1.7.1 requires menatwork/contao-multicolumnwizard 3.3.8 -> satisfiable by menatwork/contao-multicolumnwizard[3.3.8].
    - Conclusion: don't install menatwork/contao-multicolumnwizard 3.3.8


$ php composer.phar why-not menatwork/contao-multicolumnwizard
contao-legacy/semantic_html5      1.1.7.9014    requires  contao-legacy/multicolumnwizard (>=3.0.0,<4.0.0-dev)  
metamodels/attribute_alias        2.0.0-alpha2  requires  menatwork/contao-multicolumnwizard (~3.3)             
metamodels/core                   2.0.0-alpha9  requires  menatwork/contao-multicolumnwizard (~3.3)             
psi/news4ward                     2.2.3         requires  menatwork/contao-multicolumnwizard (~3)               
terminal42/contao-changelanguage  3.1.0         requires  menatwork/contao-multicolumnwizard (^3.3)     

I checked all the requires printed from why not and 3.3.8 is already green, i.e. satisfied on https://semver.mwl.be/#?package=menatwork%2Fcontao-multicolumnwizard&version=%5E3.3&minimum-stability=stable

What is going on?

Deleting the composer.lock also did not help.

Composer version is latest stable.

Composer.json

{
    "name": "local/website",
    "description": "A local website project",
    "type": "project",
    "license": "proprietary",
    "require": {
    "cgo-it/news4ward-rateit": "dev-master",
    "contao-legacy/ce_page_teaser": "~1.5",
    "contao-legacy/efg": ">=2.2.1.9005,<2.3-dev",
    "contao-legacy/om_searchkeys": "~1.0",
    "contao-legacy/rocksolid-columns": ">=1.0.6.9006,<1.1-dev",
    "contao-legacy/semantic_html5": ">=1.1.7.9014,<1.2-dev",
    "contao-legacy/survey_ce": "3.0.2.9003",
    "imi/imi_mm_changelanguage": "*",
    "jakeasmith/http_build_url": "^1",
    "madeyourday/contao-rocksolid-columns": ">=1.0.7.0,<1.1-dev",
    "metamodels/bundle_all": "dev-master",
    "phpoffice/phpexcel": "dev-master",
    "psi/news4ward": ">=2.2.3.0,<2.3-dev",
    "psi/news4ward_archive-menu": "2.0.8",
    "psi/news4ward_author-menu": "2.0.2",
    "psi/news4ward_comments": "2.1.0",
    "psi/news4ward_metatitle": "dev-master#d2c09fb47441c05011ddcc5b08e54aae138a8ab7",
    "psi/news4ward_mostread": "2.1.0",
    "psi/news4ward_multicategories": "1.0.5",
    "psi/news4ward_related": "2.1.0",
    "psi/news4ward_tags": "2.1.1",
    "contao-community-alliance/dc-general": "^2.0.0-beta32",
    "querypath/QueryPath": "^3.0",
    "terminal42/contao-changelanguage": "^3.1",
    "contao-community-alliance/composer-client": "~0.14",
    "delahaye/dlh_googlemaps": "^2.2",
    "contao-legacy/inputvar": "1.1.1.9048"
    },
    "prefer-stable": true,
    "minimum-stability": "dev",
    "config": {
    "preferred-install": "dist",
    "cache-dir": "cache",
    "component-dir": "../assets/components"
    },
    "repositories": [
    {
        "type": "artifact",
        "url": "packages"
    },
    {
        "type": "composer",
        "url": "https://legacy-packages-via.contao-community-alliance.org/"
    }
    ],
    "extra": {
    "contao": {
        "migrated": "done"
    }
    }
}
Alex
  • 32,506
  • 16
  • 106
  • 171
  • Can we see the `composer.json` too? – Pᴇʜ Mar 15 '17 at 13:39
  • @Peh I added it above – Alex Mar 15 '17 at 14:16
  • That does seem weird. However, you chould change some of your `contao-legacy` requirements to their native packages (`semantic_html5` and `rocksolid-columns` for instance). – fritzmg Mar 15 '17 at 14:19
  • 1
    I see several generic problems with your `composer.json`: 1. You are depending on `dev-master` versions. 2. You are depending on fixed versions. 3. You are depending on abandoned versions. However, copying it to a local file and running `composer update` resulted first in a complaint about the first repository not being available, and after removing it, Composer complained about not being able to install `contao-legacy/survey_ce 3.0.2.9003`, because that version does not exist. – Sven Mar 15 '17 at 16:20

1 Answers1

2

Copying your composer.json to a local file, removing the artifact repository from it, and running composer install results in a message that legacy/survey_ce 3.0.2.9003 cannot be found. However, 3.0.2.9005 is reported to be available, so I continue with that.

Running composer install again results in a resolvable set of dependencies. Running your composer require command again results in the same error message you got. I assume I am in the same spot now.

Running composer show to list all installed packages reveals that the offending package is already installed in version 3.3.10.

menatwork/contao-multicolumnwizard               3.3.10             MultiColumWizard for Contao OpenSource CMS

That explains why the dependency could not be installed, because Composer usually does not make downgrades of packages that already are installed. However, the hints being given fom it are not really explaining what is going on.

As I mentioned in my comment, you should try to overhaul your dependencies immediately:

  1. You are depending on fixed versions. Check if you can relax the version numbers to allow for compatible updates. This is easiest if the library authors state that they support semantic versioning, and it also is easy if they state that they explicitly NOT support it if they also state how to get to patches.
  2. You are depending on dev-master versions. Depending on branches will break your project at some point! Check if the library you are using has released tagged versions. Check which version you are currently referencing closest. Change your dependency from dev-master to that version (including compatible updates, as discussed in the first point) and see if your project still works.
  3. You are also depending on abandoned versions. You should upgrade the dependency to the package referenced - however this is by no means guaranteed to be an effortless transformation, some changes might be required. But it will help reduce the amount of packages involved, because it seems like many of the contao-legacy libs are re-released as menatwork, and do get updates. And these libraries should be able to be switched.
Sven
  • 69,403
  • 10
  • 107
  • 109
  • 1
    The dependency on a fixed `menatwork/contao-multicolumnwizard` version comes from `Kuestenschmiede/con4gis_core`. I have reported it here: https://github.com/Kuestenschmiede/con4gis_core/issues/28 It has only been changed in the dev branch so far. – fritzmg Mar 15 '17 at 19:55
  • Awesome, thanks for your service, also @fritzmg - I think we shall also make a request to composer concerning providing better messages ? – Alex Mar 16 '17 at 14:32
  • 1
    Getting better messages concerning the resolution of dependencies is not easy because basically you can only tell if they could be resolved or not - investigating why something failed is very hard to explain to the user because it could be many factors. However, I prepared a feature request that should be possible to implement because it is based on existing knowledge: https://github.com/composer/composer/issues/6272 Let's see if the maintainers can do something about it. – Sven Mar 16 '17 at 17:09