Closed (duplicate)
Project:
Drupal core
Version:
9.1.x-dev
Component:
composer
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
29 Oct 2019 at 17:19 UTC
Updated:
25 Jun 2020 at 19:07 UTC
Jump to comment: Most recent
Comments
Comment #2
MixologicComment #3
greg.1.anderson commentedMaybe we should change the template projects themselves to contain `~8.8.0`, `~8.9.0`, etc.; that way, if someone runs `composer create-project drupal/recommended-project:~8.8.0`, then they will get the latest `8.8.x` version of drupal/recommended-project, which will also also have `drupal/core-recommended:~8.8.0` as a dependency. If on the other hand they use `^8.8` instead of `~8.8.0` with `create-project`, then they will get the latest 8.x release of drupal/recommended-project, which will be 8.9.0 (if not today, imagine some point in the future when it will), which will have `drupal/core-recommended:~8.9.0`. This would be fairly consistent with how Composer is expected to behave.
The odd part is if someone tries to run `composer create-project drupal/recommended-project:8.7.5` in an attempt to specifically pin drupal/core-recommended to a specific version, then they will still get `drupal/core-recommended:~8.8.0` in their resulting project, because that's what is in every 8.8.x version of the template.
Our other option would be to add a composer post-create-project script to fix up the composer.json of the resulting project after the fact (and then remove itself). However, I am not sure that it's easy to get the constraint the user provided on the create-project commandline at post-create-project time, and in general I am wary about doing that much work to change the basic behavior of Composer. Perhaps we should be satisfied with what we can do with standard features and document the behavior.
Comment #4
ultimikeDuring the DrupalCon Amsterdam contribution sprint, it was discussed that adding a code-based solution was not advantageous for a few reasons. It would be necessary to somehow pass the core version from `composer -n create-project drupal/recommended-project:VERSION` to the require section in order to specify the exact version of drupal/core-recommended. There is no native/easy way to do this with Composer. We discussed possibly doing this via a Composer hook or via a .env file, but neither potential solution was very elegant or Composer-y. Therefore, marking this issue as "Closed (won't fix)".
The current consensus is to provide documentation for users on how to specify an exact version of Drupal core, when necessary.
For example, to use drupal/recommended-project to install the latest stable version of Drupal core, use (once Drupal 8.8 is released):
`composer -n create-project drupal/recommended-project:~8.8.0 my-project`
Similarly, if you want to install the latest dev version (once #3091581: Create generator scripts to customize drupal/recommended-project and drupal/legacy-project per minor Drupal version lands):
`composer -n create-project drupal/recommended-project:~8.8.0@dev my-project`
or
`composer -n create-project drupal/recommended-project:~8.9.0@dev my-project`
**Note to self, check #??? to see if/when a change is made to drupal/recommended project where dependency versions track with the branch.
If you would like to install a specific version of Drupal core for versions prior to 8.8.0,
`composer -n create-project drupal/recommended-project:8.7.5 --no-install my-project; cd my-project; composer require drupal/core-recommended:8.7.5 drupal/core-dev:8.7.5 --update-with-dependencies`
Once #3091579: Remove core-dev from drupal/recommended-project Composer template lands, `drupal/core-dev` doesn't need to be included.
In the future, as maintenance releases of 8.8 are released, the following would be used for a specific 8.8.x version:
`composer -n create-project drupal/recommended-project:8.8.2 --no-install my-project; cd my-project; composer require drupal/core-recommended:8.8.2 drupal/core-dev:8.8.2 drupal/core-composer-scaffold:8.8.2 --update-with-dependencies`
Comment #5
MixologicSo.. Im going to reopen this because I had some thoughts.
The reason that we cannot specify an exact version is because we have an additional layer between
drupal/recommended-projectanddrupal/core(drupal/core-recommended).IIRC this layer was added because the community kept having difficulty upgrading their sites when they had *both* the dev dependencies and drupal/core required, and thus needed people to know that in order to upgrade core, they had to upgrade
drupal/coreandwebflo/drupal-core-require-dev- the goal being to simplify upgrades.However, it has proven to not be effective in not conflicting with the require-dev in the templates, and as such we've made a separate decision to attempt to remove them in #3091579: Remove core-dev from drupal/recommended-project Composer template, and we've also renamed them to make it easier to dual upgrade core and core-dev at the same time if need be.
So, _perhaps_ the solution to allow for exact versioning is to remove the indirection entirely, and to move the require for
drupal/coreup to the template project (indrupal/recommended-projectanddrupal/legacy-project) and out of core-recommended.The upside is that
composer create-project drupal/recommended-project:8.7.5would give us the exact right version of core specified and not whatever the newest one was.The downside is that *major version upgrades of core*, which are by definition rare, would then need to include
drupal/core-recommended,drupal/core, anddrupal/core-dev(if installed).Comment #6
greg.1.anderson commented#5 does not actually help.
That is not the case. When you run
composer create-project drupal/recommended-project:8.7.5, you will get version 8.7.5 of the core-recommended-project. However, all versions of Drupal core-recommended containdrupal/core-recommended: ^8.8. Even if we change this todrupal/core-recommended:~8.8.0ordruapl/core:~8.8.0, the basic behavior will be the same: the version of drupal/core will float.What we could do is put
drupal/core-recommended: 8.7.5in the 8.7.5 version of drupal/recommended-project. That would make the create-project behave exactly as expected when installing a tag. Unfortunately, it would prevent upgrades for users who were asking for drupal/core-recommended:^8.8, so that solution is no good either.In order for things to work right for all scenarios, we need the version used on the command line to be copied into the resulting project's composer.json file. The fact that Composer does not provide a facility to do that by default is the crux of the problem.
Comment #7
MixologicAh, right, Im not sure why I thought the extra layer was causing the float. Call it jetlag.
So, the other option we could use is ship the templates with a composer.lock file that started the template at the specified version.
composer.json would have
drupal/core-recommended: ^8.8and the composer.lock file would have
drupal/core-recommended: 8.8.0for the 8.8.0 version ofcore/recommended-projectWhen we talked about making lock files for the templates, it was determined that users would *start* with a known set of deps, but would quickly end up 'out of bounds' on deps that hadnt yet been tested, so we settled on the core-recommended pinned 'direct' dependencies of core to shield end users from upstream changes.
But if we had *both* we could start end users with a specific version of
drupal/core-recommended, and thencomposer updatewould still work as expected as well.composer requirewould still be necessary for major version upgrades however, but there's really no way around that need.Comment #8
Mixologicrelated grooming
Comment #9
greg.1.anderson commentedYeah, I forgot about the composer.lock angle. We should try that.
Comment #10
mile23The way we should tell people to get a specific version of core using templates is as follows:
Here's a variation that works with current releases (we're at beta1):
Now the user understands how these pieces work together, and understands how they can get updates to core by either requiring the specific patch version, or changing to ~8.8.
Adding a lock file and all that other stuff only complicates matters unnecessarily.
Comment #12
karimb commentedBtw, just tested
composer create-project drupal/recommended-project:^8.9 myprojectto download Drupal 8.9.1It seems working like a charm so far.
Comment #13
greg.1.anderson commentedThis was fixed in the Drupal.org infrastructure subtree splitter, subtree-splitter#2.