requiring the module with composer generates an error because of the jsonapi dependency of the contrib module.

Change this to the core version.

CommentFileSizeAuthor
#2 allow_drupal_core_install_3066962.patch405 bytesyobottehg
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

yobottehg created an issue. See original summary.

yobottehg’s picture

Assigned: yobottehg » Unassigned
Status: Needs work » Needs review
FileSize
405 bytes

here the needed change.

mglaman’s picture

Status: Needs review » Needs work

It would be better to provide a composer.json so that info.yml does not have to be parsed. drupal/jsonapi package maps to contrib and core as appropriate.

EDIT: I am wrong, the namespaced dependency change also needs to be changed. The above is still more declarative versus the automatic composer.json generation based off of info.yml

hussainweb’s picture

@mglaman, are you saying that the patch is more declarative? If so, I agree. I don't really see the need for composer.json here. I have seen a module's composer.json drift from the info.yml often.

mglaman’s picture

Status: Needs work » Needs review

I'll kick back to Needs Review. I strongly believe the composer.json should be used instead of the Composer facade dynamically generating one off of the info.yml, but that's the maintainer's call.

sashainparis’s picture

Well, well...

I am using composer where I declared "jsonapi_boost": "^1.0" as a requirement. So I get it :-)

From my understanding, composer manage code dependencies while info file manage application dependencies. As a consequence, even if Drupal try to manage code dependencies through info file, it went wrong.

As I use composer, I want to apply the patch to make sure it knows about JsonAPI in Core:

  "patches": {
    "drupal/jsonapi_boost": {
      "Allow module install with composer and JSON:API in core": "https://www.drupal.org/files/issues/2019-07-10/allow_drupal_core_install_3066962.patch"
    }
  },

I believe this will properly:

  1. Patch the info file
  2. Force Drupal to apply application dependencies rules when I will enable the module

But... all this comes after composer had finished with evaluating dependencies between modules / packages in my project. So composer actually looked for drupal/jsonapi and rejected my composer requirements:

Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Conclusion: remove drupal/core 8.7.5
    - webflo/drupal-core-require-dev 8.7.5 requires drupal/core 8.7.5 -> satisfiable by drupal/core[8.7.5].
    - webflo/drupal-core-require-dev 8.7.5 requires drupal/core 8.7.5 -> satisfiable by drupal/core[8.7.5].
    - Conclusion: don't install drupal/core 8.7.5
    - drupal/jsonapi_boost 1.x-dev requires drupal/jsonapi ^2.0 -> satisfiable by drupal/jsonapi[2.x-dev, 2.4.0, 2.3.0, 2.2.0, 2.1.0, 2.0.0, 2.0.0-rc4, 2.0.0-rc3, 2.0.0-rc2, 2.0.0-rc1, 2.0.0-beta2, 2.0.0-beta1].
    - drupal/jsonapi_boost 1.0.0-rc1 requires drupal/jsonapi ^2.0 -> satisfiable by drupal/jsonapi[2.x-dev, 2.4.0, 2.3.0, 2.2.0, 2.1.0, 2.0.0, 2.0.0-rc4, 2.0.0-rc3, 2.0.0-rc2, 2.0.0-rc1, 2.0.0-beta2, 2.0.0-beta1].
    - don't install drupal/jsonapi 2.x-dev|don't install drupal/core 8.7.x-dev
    - don't install drupal/jsonapi 2.4.0|don't install drupal/core 8.7.x-dev
    - don't install drupal/jsonapi 2.3.0|don't install drupal/core 8.7.x-dev
    - don't install drupal/jsonapi 2.2.0|don't install drupal/core 8.7.x-dev
    - don't install drupal/jsonapi 2.1.0|don't install drupal/core 8.7.x-dev
    - don't install drupal/jsonapi 2.0.0|don't install drupal/core 8.7.x-dev
    - don't install drupal/jsonapi 2.0.0-rc4|don't install drupal/core 8.7.x-dev
    - don't install drupal/jsonapi 2.0.0-rc3|don't install drupal/core 8.7.x-dev
    - don't install drupal/jsonapi 2.0.0-rc2|don't install drupal/core 8.7.x-dev
    - don't install drupal/jsonapi 2.0.0-rc1|don't install drupal/core 8.7.x-dev
    - don't install drupal/jsonapi 2.0.0-beta2|don't install drupal/core 8.7.x-dev
    - don't install drupal/jsonapi 2.0.0-beta1|don't install drupal/core 8.7.x-dev
    - webflo/drupal-core-require-dev 8.7.x-dev requires drupal/core 8.7.x-dev -> satisfiable by drupal/core[8.7.x-dev].
    - Installation request for webflo/drupal-core-require-dev ~8.7.5 -> satisfiable by webflo/drupal-core-require-dev[8.7.5, 8.7.x-dev].
    - Installation request for drupal/jsonapi_boost ^1.0 -> satisfiable by drupal/jsonapi_boost[1.x-dev, 1.0.0-rc1].

Which is pretty stupid, right? (in fact, before I replaced "^7.0" by "^7.5", it downgraded Drupal Core to 8.x-7.5-RC2!

We just need a composer file. Without it this module can't be used with composer.

Here is a basic template based on the above patch for composer.json:

{
  "name": "drupal/jsonapi_boost",
  "type": "drupal-module",
  "description": "Improve the performance of the JSON:API module with a cache-warming strategy.",
  "license": "GPL-2.0+",
  "homepage": "https://www.drupal.org/project/jsonapi_boost",
  "authors": [
    {
      "name": "Mateu Aguiló Bosch",
      "homepage": "https://www.drupal.org/u/e0ipso"
    }
  ],
  "support": {
    "issues": "https://www.drupal.org/project/issues/jsonapi_boost",
    "source": "http://cgit.drupalcode.org/jsonapi_boost"
  },
  "require": {
    "drupal/jsonapi_extras": "^3.0",
    "drupal/warmer": "^1.0"
  }
}

Nothing about as JsonAPI as... it is in Core.
I filled your name as maintainer. Please review and commit ;-)

Regards,

sashainparis’s picture

Category: Feature request » Bug report
Priority: Normal » Critical
Issue tags: +Composer
hussainweb’s picture

@sashainparis, if I understand the output correctly, this error will be fixed if the patch we have in #2 is committed.

The Composer facade is using the .info.yml file to build the dependency graph and that is incorrect right now and the patch fixes that. Once the patch is committed, the d.o packager will update the generated composer.json as well.

Either way, I don't have strong opinions on having composer.json or not. I am just saying that I have seen it drift from the module's actual requirements before and hence I avoid it unless it is required. Here, I don't think it is required. We just need to commit the patch and also probably create a release.

sashainparis’s picture

Hi,

We need both:
- apply the patch #2 for Drupal API reasons (dependencies while enabling the module)
- add a composer.json file based on the template I gave in #6 (dependencies while building project code)

Regards,

hussainweb’s picture

> add a composer.json file based on the template I gave in #6 (dependencies while building project code)
When the patch in #2 is applied and packaged, the composer.json will be updated to match the sample in #6. This means both problems are solved once it gets packages (not just committed).

Like I said before, my only concern with adding a composer.json is the drift that happens over time. If the maintainers feel composer.json should be there, that's fine too. It's just another file to maintain for no reason as far as I can see.

e0ipso’s picture

This patch assumes that you are running >=D8.7. At the time of writing this D8.6 has not reached EOL yet.

e0ipso’s picture

Priority: Critical » Major
e0ipso’s picture

  • e0ipso committed 7b6da45 on 8.x-1.x authored by yobottehg
    Issue #3066962 by yobottehg, hussainweb, sashainparis, e0ipso, mglaman:...
e0ipso’s picture

Status: Needs review » Fixed

I decided to make this module >=8.7

Merged.

hussainweb’s picture

Thanks @e0ipso,

With this, I see the composer require works for me:

~/w/cms   *…  composer require drupal/jsonapi_boost                                                                                                                        Thu Aug  8 17:49:30 2019
    1/14:       https://packages.drupal.org/8/drupal/provider-2017-4$f85c708eda55d61eef0f58eafdb76f457832ae2cbc88ba1138287908d28610c8.json
    2/14:       https://packages.drupal.org/8/drupal/provider-2017-3$13c25dfbac099689da9c817ce061f279b2cb2e6bb9fa3bcb4a57230ee3d1da72.json
    3/14:       https://packages.drupal.org/8/drupal/provider-2018-1$39e5e8def9bb0c829e4fe6d272f0c040f458b4497bbb0b7bf4158c22c6fc5e97.json
    4/14:       https://packages.drupal.org/8/drupal/provider-2018-2$3e6166584aa70cea7f6d687299d216b88317192542bac707d154a6b19bd0fa86.json
    5/14:       https://packages.drupal.org/8/drupal/provider-2018-3$7bcc4f61ac1f8d8598d0be3d0035ac63a486c8cdd47481891d75f1874d61909d.json
    6/14:       https://packages.drupal.org/8/drupal/provider-2016-4$f58468f0ed02ab9224c5984491c35d0ace4a282ff99e7b2b267c19976ff4fca9.json
    7/14:       https://packages.drupal.org/8/drupal/provider-2017-2$4a7102daccca01a7f9ca83bb1b73e8d13a263fc3def6e5519320465c36f1964e.json
    8/14:       https://packages.drupal.org/8/drupal/provider-2016-2$6fa11ef51412122bf6862aeb785f533a20ac559ee3fe52e80eef72f4e441e38c.json
    9/14:       https://packages.drupal.org/8/drupal/provider-2018-4$b2de8f21853552f9e36830989aafc9f480e24ee6181af8782654ff48efd8d464.json
    10/14:      https://packages.drupal.org/8/drupal/provider-2016-3$d7861eb8c0f0147bcc3676c310c3716e6e760a234952aaad10091a0af6f96a61.json
    11/14:      https://packages.drupal.org/8/drupal/provider-2019-1$802d0dc170f377faa33b67d59f36c36eb45aa7770c15df8cc95ada7231564697.json
    12/14:      https://packages.drupal.org/8/drupal/provider-2019-2$6e36250de57e1481714402a58465cdab0c058d58074fa66cc16223006f2abe45.json
    13/14:      https://packages.drupal.org/8/drupal/provider-2017-1$1053180c1805402560b316c084e435abccbff6058752e97dcfffd8fc17efaa40.json
    14/14:      https://packages.drupal.org/8/drupal/provider-2019-3$0a5c5ae4a78edf6e4945fa1c24aecd30c41d5068531bf9d26a507d4932fceb58.json
    Finished: success: 14, skipped: 0, failure: 0, total: 14
    1/12:       http://repo.packagist.org/p/provider-archived$5706431ce40cc3e8240ff4f5f3e9b4bc22bb8340bfd5ffa2af884277b6539968.json
    2/12:       http://repo.packagist.org/p/provider-2019-07$feb6352fa9294ad2cf509810ced2e9afb5150bf5f343b7d345579cd94257ad63.json
    3/12:       http://repo.packagist.org/p/provider-latest$390969a3e4622bef07d9c79c1f1a70f44cc382117738744c6414b73d9b355e54.json
    4/12:       http://repo.packagist.org/p/provider-2013$ef779a68e80430098c0d22b21d23c5eb5fdf5641cbb89a85f7b149e9eff06ed7.json
    5/12:       http://repo.packagist.org/p/provider-2019-04$948f59891be0e9ef30b8695b781bfa71ec8448ee59233470719e2f1655bd5d68.json
    6/12:       http://repo.packagist.org/p/provider-2014$d0cccb170d8b85ccb5b79fbc42eccd247739a3820fa8b7e2a3aaa670e1e8041d.json
    7/12:       http://repo.packagist.org/p/provider-2018-10$f8e4145377a6e7a290a55647546cf0a63944c6d3efc16af5e72b23e99bb54146.json
    8/12:       http://repo.packagist.org/p/provider-2019-01$3a3b628a375e68e97e88935f3d4e18f5af73928ed7083de07f6cfd540d027c78.json
    9/12:       http://repo.packagist.org/p/provider-2015$aa5bc7faf3736e5b9f7b92e31a28fa03656a0b6270bfaf61939b9426f21f09ee.json
    10/12:      http://repo.packagist.org/p/provider-2017$d202fcf0c85509bcd684b5ad37063d28001656ada7a544d67a616686b032e574.json
    11/12:      http://repo.packagist.org/p/provider-2016$5634054b1e3258b0a907cec6ca872d5aa58d72c0dd834ee68399baacfa5d2369.json
    12/12:      http://repo.packagist.org/p/provider-2018$2472ddeb425c3043b3e042a1434a2ec92049b229cae749324101f38158a7fb7b.json
    Finished: success: 12, skipped: 0, failure: 0, total: 12
Using version ^1.0@RC for drupal/jsonapi_boost
./composer.json has been updated
    1/2:        http://repo.packagist.org/p/provider-latest$5d4232dff5f066fe2a523c4144d845eeb50915408180e10415fc03d6772e9268.json
    2/2:        http://repo.packagist.org/p/provider-2017$b8fb1e0bf68d61c74e237159a90a8ce4db1a2c73028622e1855c63d1091bd4ae.json
    Finished: success: 2, skipped: 0, failure: 0, total: 2
Loading composer repositories with package information
Updating dependencies (including require-dev)
    1/5:        https://ftp.drupal.org/files/projects/jsonapi_boost-8.x-1.0-rc2.zip
    2/5:        https://ftp.drupal.org/files/projects/jsonapi_extras-8.x-3.8.zip
    3/5:        https://codeload.github.com/e0ipso/shaper/legacy.zip/a9b1420201ca3d0831d91879f72bf90e1186fd32
    4/5:        https://codeload.github.com/VIPnytt/SitemapParser/legacy.zip/57cb0dcac0e9a51b6a5287a0672d30f6827fdc3d
    5/5:        https://ftp.drupal.org/files/projects/warmer-8.x-1.0.zip
    Finished: success: 5, skipped: 0, failure: 0, total: 5
Package operations: 5 installs, 0 updates, 0 removals
  - Installing vipnytt/sitemapparser (1.0.4): Loading from cache
  - Installing drupal/warmer (1.0.0): Loading from cache
  - Installing e0ipso/shaper (1.2.2): Loading from cache
  - Installing drupal/jsonapi_extras (3.8.0): Loading from cache
  - Installing drupal/jsonapi_boost (1.0.0-rc2): Loading from cache
Package egeloen/http-adapter is abandoned, you should avoid using it. Use php-http/httplug instead.
Package phpunit/phpunit-mock-objects is abandoned, you should avoid using it. No replacement was suggested.
Writing lock file
Generating autoload files
sashainparis’s picture

OK for me too.
It seems that D.O. provides composer data dynamically based on info files as no composer file is generated to be dowloaded.

Thanks.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.