Problem/Motivation

When building a drupal site with composer, it can be helpful to not simply retrieve the "latest versions" of everything, and instead constrain the set of available packages to the most recent set of packages that have been thoroughly tested with drupal core during normal development drupalci runs.

This is needed because if we have multiple potential kickstart plugins, they would all need to use this plugin.

Proposed resolution

Provide a package, similar to https://github.com/webflo/drupal-core-strict, that enshrines core's lock file as a dependency that can be included with the various kickstart plugins.
Probably leverage https://github.com/webflo/package-generator-drupal to keep this up to date on an ongoing basis.

Remaining tasks

Figure out what the workflow should be to use https://github.com/webflo/package-generator-drupal. Does core run this when they update the lock file? Is there something automated that does this?

Comments

Mixologic created an issue. See original summary.

Mixologic’s picture

Issue tags: +Composer
Mixologic’s picture

Issue summary: View changes
Mixologic’s picture

We might not actually want to do this. It gives the benefit of having a strict set of dependencies, but at the cost of making upgrades more difficult. Upgrading would require users to upgrade *both* drupal/core as well as drupal/core-strict, and if core *adds* a dependency that might cause issues as well.

Not having a strict set means that we risk having a state where we cant create the product if there is an upstream breakage in a dependency, which probably wouldnt be a big deal for the tarball, but might make composer create-project drupal/kickstart fail under certain conditions

Mixologic’s picture

So one thing that I was experimenting with is what happens when there is a composer.lock file that is included within the drupal/drupal-project-legacy repository when `composer create project` is executed:

Short answer is it works, except we cant just use the lockfile thats checked into drupal/drupal because it lacks the drupal/core and drupal/drupal-scaffold repositories.

I hacked together a composer.json that took the packages key from drupal/drupal's lock file, and merged it with the packages key from drupal/drupal-project-legacy after I ran a composer install, keeping only the drupal/core and drupal/drupal-scaffold keys, and lo and behold it installed the exact dependencies we want, without having the rigid requirement in the root composer.json - so if there's some way that we can generate these 'combined lock' files for the project templates, that would be ideal.

bonus points if that process can be reused by distro maintainers to also get a starting point of precise core dependencies.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Mixologic’s picture

We've identified a few mechanisms for how a drupal site should be managed with regards to the dependency management strategy we should adopt.

1. A core strict plugin that locks the dependencies to a specific version for each core dependency.

Pros:

  • We can guarantee that the dependencies that the end user has have been tested, and they will not get a surprise upgrade

Cons:

  • Upgrades are more complicated, because they have to upgrade core, and the core strict plugin at the same time.
  • Having a very narrow set of acceptable dependencies can cause conflicts when adding newer modules with 3rd party dependencies.
  • Possible that some dependencies have to be different between php7 , 7.1., 7.2, 7.3, and thus there is no "one true set of deps" that we can ship with.

This requires core to maintain the plugin in conjunction with the core lock file.
This Option is 'maximal safety'

2. A lock file that lives in conjunction with the template files

Pros:

  • This would guarantee that when the tarball is constructed, or when the end user starts with a `composer create project drupal/{templatefile}`that they begin with a known, working set of dependencies, and do not start with any broken upstream surprises.
  • No conflicts when adding modules,
  • Upgrading is simpler (composer update drupal/core should be sufficient)

Cons:

  • When users update core, or potentially add modules, their dependencies could update to the latest versions of dependencies

This would require that core maintains the lock files of any templates that it ships with. This one is 'Less safe, but flexible, and no risk of a broken product out of the box'

3. No restrictions, cowboy.

Pros:

  • Most flexible, least amount of maintenance

Cons:

  • Potential exists for an upstream bug to be introduced in a dependency, and an end users first attempt to use drupal is broken.

So, due to the nature of semver and dependency hell, there's really no way to simultaneously guarantee a set of dependencies that will work with drupal, and also guarantee flexibility in extending and upgrading.

In other words, this decision is really a 'what level of safety should we offer to our users?

Currently, we can see that there are a substantial number of sites out there that have selected option 3.

If we look at the download numbers for
https://packagist.org/packages/drupal-composer/drupal-project, it currently shows 230 695 installs, but that doesnt show the whole picture because there are many, many forks of that project.
A better place to look would be https://packagist.org/packages/drupal-composer/drupal-scaffold, because most of the forks still rely on that project. It has 2,488,381 downloads, whereas

https://packagist.org/packages/webflo/drupal-core-strict, the current implementation of option 1, only shows 154 980 downloads.

So, maybe option 3 isnt really all that risky? (or 2, for added comfort)

Mixologic’s picture

phenaproxima’s picture

Thanks for summarizing, @Mixologic!

Speaking as a distro maintainer, I feel like the option which would be most useful to the most users is option #2. Nobody wants to deal with the possibility of Drupal being accidentally broken out of the box, but once they do have a working Drupal, nobody wants to be overly constrained by Composer. I think option #2 offers the optimum mix of safety and flexibility.

balsama’s picture

Thanks for doing the research! My 2¢:

Given that Mixologic confirms in #5 that lock files present in scaffold projects are respected when running create-project, we don't need to worry about composer create-project drupal/kickstart failing when new upstream releases are made. 🎉 And we won't be unnecessarily constraining consuming apps or contrib modules that need a different minor version of some dependency. So +1 to Option #2. We should probably confirm with the Composer folks that this is the intended behavior and that were not relying on a fluke that could change.

Given that there is a desire for an optional strict package as well (and that's a big given), could we consider just adding drupal/core as a dependency to drupal/core-strict? That way users wouldn't have to update both at the same time. They would just require drupal/core-strict instead of drupal/core if they need the extra guardrails. I really wish we could pass an option to create-project so that we could do something like composer create-project drupal/kickstart --strict. But I think we'd actually need two kickstart projects in this case, one that required drupal/core and one that required drupal/core-strict.

Summary:

  1. +1 to Option 2, but we should confirm that this works as designed if we haven't already.
  2. If we need to offer a strict package, we should consider having it require drupal/core so that users would require one or the other, not both.
Mixologic’s picture

consider just adding drupal/core as a dependency to drupal/core-strict

Ah, yes, thats a much better option for the maximum safety option. ++

But I think we'd actually need two kickstart projects in this case, one that required drupal/core and one that required drupal/core-strict.

And our ability to have multiple kickstarts that ship with core is a feature of this architecture.

we should confirm that this works as designed if we haven't already.

Im pretty sure thats the intended behavior, as thats the only way to interact with a lock file directly from composer without already having git clone of a project, but I can reconfirm that.

Mixologic’s picture

Title: Add a composer core-strict plugin to core » Add a core lockfile creator to generate template lockfiles.

Okay, I've got an experiment up and running at https://github.com/drupal/drupal-project-legacy which includes a .lock file.

Im very confident in this going forward, so Im going to go ahead and repurpose this issue to be where we add a script to core such that when core commits a new lock file to the repo, it subsequently updates the lock files in any of the template projects such that templates moving forward begin with the correct dependencies.

This script *may* be of use to distribution maintainers as well, under the assumption that they too may wish to have a similar lock file shipped with their starting point templates.

I do not see this script as being a blocker moving forward, more like a convenience to make it easier or core maintenance to ensure that the template locks are kept in sync with core's .lock file changes.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Mixologic’s picture

Update on this issue:

We'll continue to have a lockfile in the root of the repository, and we'll use that to create a metapackage for 'core-pinned-dependencies'.

This metapackage will have cores dependencies pinned to specific versions, and will require drupal/core itself.

This will allow consumers of this package to avoid having to update both drupal/core and drupal/core-pinned-dependencies at the same time.

The metapackage creation should be a process that runs on drupal.org's infra and extracts the info from the lockfile.

Mixologic’s picture

drupal/core-recommended-dependencies

is the name we're settling on.

Mixologic’s picture

mile23’s picture

Mixologic’s picture

Status: Active » Closed (won't fix)

I probably should have just moved this over to drupal infrastructure, but theres really nothing to commit to core for this issue. closing in favor of the other issue now.