GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Edit Task
  • Edit Related Tasks...
  • Create Subtask
  • Edit Parent Tasks
  • Edit Subtasks
  • Merge Duplicates In
  • Close As Duplicate
  • Edit Commits
  • Edit Mocks
  • Mute Notifications
  • Protect as security issue
  • Composer
  • (Features/Improvements)
  • Upstream

This view

  • Original page
  • New address

GeezerVison is showing phabricator.wikimedia.org — T173141 Provide a way to install Composer dependencies after installing an extension, without updating all unrelated libraries

Page MenuHomePhabricator
Log In
Create Task
Maniphest T173141

Provide a way to install Composer dependencies after installing an extension, without updating all unrelated libraries
Open, Needs TriagePublic
Actions

  • Edit Task
  • Edit Related Tasks...
  • Create Subtask
  • Edit Parent Tasks
  • Edit Subtasks
  • Merge Duplicates In
  • Close As Duplicate
  • Edit Related Objects...
  • Edit Commits
  • Edit Mocks
  • Mute Notifications
  • Protect as security issue
Assigned To
None
Authored By
Tgr
Aug 11 2017, 8:41 PM2017-08-11 20:41:07 (UTC+0)
Project Tags
  • Composer (Features/Improvements)
  • Upstream (Backlog)
  • MediaWiki-General (Backlog)
Referenced Files
None
Subscribers
ahmad
Aklapper
dbarratt
Esanders
freephile
Jonathan3
Kghbln
View All 12 Subscribers

Description

When installing/updating an extension which has Composer dependencies, there are three approaches:

  1. run composer update in the main MediaWiki directory. This will cause composer to collect all dependencies (including the dependencies of the changed/new extension) via composer-merge-plugin, and update them. The result is always correct but will update every library to the newest version allowed by composer.json, not just the ones for the newly installed extension. Besides taking longer, more code changes means a higher probability of something breaking, thus more effort needed to test that the site works correctly.
  2. run composer install in the extension directory. This usually works (as long as the extension is able to use the autoloader from its vendor subdirectory, e.g. by setting the load_composer_autoloader flag in extension.json), and does not do unnecessary updates. It can fail in one edge case though: when the extension uses a library that is also used by another extension or MediaWiki core, Composer is not able to merge the version requirements and calculate the correct version (or throw an error if they conflict). Thus, there will be two different versions of the library, and callers might end up with a library version they did not expect.
  3. run composer update --with-dependencies library/one library/two ... to manually limit updates to the libraries needed by the extension. This works but is fairly cumbersome.

It would be nice to have a simpler way to install/update the affected libraries only.

Upstream bug: #6601

Related Objects

  • Mentions
Mentioned In
T402730: Error: Class "MediaWiki\OAuthClient\ClientConfig" not found
T382882: Special:CheckUser Error: Class "Firebase\JWT\JWT" not found
T248925: Make MediaWiki release tarball compatible with PHP 8.0
T250406: RFC: Hybrid extension management
T166956: Cannot use Composer's CLI to manage a project's dependencies
T178137: MediaWiki-Vendor creates a scenario in which incompatible versions of dependencies can be present
Mentioned Here
T167038: Separate "application" and "project" concerns
T186181: Loading at-ease twice causes fatal error
T178137: MediaWiki-Vendor creates a scenario in which incompatible versions of dependencies can be present
T166956: Cannot use Composer's CLI to manage a project's dependencies

Event Timeline

Tgr created this task.Aug 11 2017, 8:41 PM2017-08-11 20:41:07 (UTC+0)
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 11 2017, 8:41 PM2017-08-11 20:41:08 (UTC+0)
Tgr added a comment.Aug 11 2017, 8:42 PM2017-08-11 20:42:01 (UTC+0)
Comment Actions

This is an upstream issue that we probably can't do much about. I mostly just created the task to have a description of the issue that can be referenced from on-wiki documentation.

Tgr updated the task description. (Show Details)Aug 11 2017, 8:42 PM2017-08-11 20:42:55 (UTC+0)
• Samwilson subscribed.Edited · Sep 18 2017, 2:25 AM2017-09-18 02:25:47 (UTC+0)
Comment Actions

This is one of the problems that composer.lock is supposed to fix, because then all dependencies are locked to a specific commit and cannot be changed. The other part of that idea is that one should never run composer update in production, but only ever composer install.

As for not wanting to update all dependencies at once, I think the current idea is that every composer file (core and extensions) should be specifying exact patch-level version numbers, and so (short of maintainers being naughty and changing a tagged version) there shouldn't be any unexpected upgrades.

I don't think there's any need to have any system of only updating some dependencies (other than, as you mention, the existing functionality in Composer). Rather, we should work towards a system in which a wiki can be deployed in a controlled way with its own composer.lock file (see also T166956, esp. the comment there "we don't trust upstream to follow semver", which I think is pertinent to this issue).

bd808 mentioned this in T178137: MediaWiki-Vendor creates a scenario in which incompatible versions of dependencies can be present.Oct 18 2017, 2:49 PM2017-10-18 14:49:07 (UTC+0)
Krinkle mentioned this in T166956: Cannot use Composer's CLI to manage a project's dependencies.Mar 21 2018, 8:43 PM2018-03-21 20:43:08 (UTC+0)
ahmad subscribed.Apr 15 2018, 2:29 PM2018-04-15 14:29:50 (UTC+0)
Liuxinyu970226 subscribed.Apr 26 2018, 12:45 PM2018-04-26 12:45:32 (UTC+0)
dbarratt subscribed.May 10 2018, 5:02 PM2018-05-10 17:02:55 (UTC+0)
Comment Actions

run composer install in the extension directory.

This would create multiple vendor directories which is an anti-pattern. It would mean that if there are conflicting dependencies (or dependencies in multiple versions) then those discrepancies will not be resolved and will have to be resolved manually. :(

I suppose this is why we have MediaWiki-Vendor (see T178137)

Tgr added a comment.May 10 2018, 5:17 PM2018-05-10 17:17:47 (UTC+0)
Comment Actions
In T173141#4198024, @dbarratt wrote:

It would mean that if there are conflicting dependencies (or dependencies in multiple versions) then those discrepancies will not be resolved and will have to be resolved manually. :(

And causes other problems like T186181. Nevertheless this is what we do currently in MediaWiki-Vagrant at least. Not sure which is the lesser evil.

With the vendor repo this is not really an issue since it is hand-curated (no on will run unrestricted composer update on it).

Seb35 subscribed.Jan 11 2019, 5:49 PM2019-01-11 17:49:21 (UTC+0)
Comment Actions

I read this bug and I am interested if it could be solved in some way. I’ve not tested yet, but if I understand correctly @dbarratt on issue #6601, there are some Composer commands which, when executed in a specific order, would solve this issue, isn’t it?

This next idea is far beyond this task, but reading this bug and having in mind other issues about MediaWiki + Composer + composer-merge-plugin + MediaWiki vs Composer autoloader + activation of MW extensions installed through Composer in a farm + numerous reactions from Composer team saying we are a very specific use case (which is probably true), I was wondering if MediaWiki should not create a dedicated binary about "installing vendor and possibly extensions/skins" and using Composer library and Packagist, but not the Composer CLI.

Tgr added a comment.Jan 11 2019, 6:03 PM2019-01-11 18:03:02 (UTC+0)
Comment Actions
In T173141#4873677, @Seb35 wrote:

I read this bug and I am interested if it could be solved in some way. I’ve not tested yet, but if I understand correctly @dbarratt on issue #6601, there are some Composer commands which, when executed in a specific order, would solve this issue, isn’t it?

Well the idea there is to basically walk the dependency graph manually, as directed by error messages. It's possible of course, but not a particularly good user experience.

I was wondering if MediaWiki should not create a dedicated binary about "installing vendor and possibly extensions/skins" and using Composer library and Packagist, but not the Composer CLI.

I don't think anyone disagrees that's the ideal solution (there was more discussion on it in one of the extension management RfCs). Question is if/when it will actually happen.

dbarratt added a comment.Jan 14 2019, 2:14 PM2019-01-14 14:14:50 (UTC+0)
Comment Actions

@Seb35 You might look at T166956 for the "MW extensions installed through Composer" side of it. I haven't tried doing so in a farm, I ran into a bunch of issues (mostly to do with the file paths) in the installer which was a black hole of despair.

Kghbln awarded a token.Jan 21 2019, 10:31 PM2019-01-21 22:31:14 (UTC+0)
Kghbln subscribed.
Krinkle updated the task description. (Show Details)Mar 26 2019, 8:31 PM2019-03-26 20:31:18 (UTC+0)
Krinkle added a project: MediaWiki-General.
Krinkle subscribed.
Comment Actions
In T173141#4877190, @dbarratt wrote:

@Seb35 You might look at T166956 for the "MW extensions installed through Composer" side of it. I haven't tried doing so in a farm, I ran into a bunch of issues (mostly to do with the file paths) in the installer which was a black hole of despair.

I understand the benefits of not having to edit a composer.local.json file. But it is unclear to why Composer's behaviour would be different between option 1 in this task description (composer-install in mediawiki dir), and a composer command in a Composer-managed project.

Do they behave differently? Is that a bug in Composer? If not, is there another way to solve it other than for Composer to offer a feature it currently doesn't have?

dbarratt added a comment.Mar 26 2019, 8:56 PM2019-03-26 20:56:42 (UTC+0)
Comment Actions

@Krinkle If I understand this correctly, if you have something like this in your composer.local.json:

{
	"extra": {
		"merge-plugin": {
			"include": [
				"extensions/GraphQL/composer.json"
			]
		}
	}
}

and you were to update the GraphQL extension, you would have no idea which packages might need to be updated. You have no idea what is in extensions/GraphQL/composer.json unless you manually go look at it, but even then you would need to do a diff to see if anything need to be removed.

The only work-around would be to do a composer update which would update literally everything.

The ideal solution would be to install the extension itself with Composer like so:

composer require mediawiki/extension-graphql

(or something like that)
That way you could then do:

composer update mediawiki/extension-graphql

and it would update only the extension and the dependencies of the extension.

freephile subscribed.Sep 11 2019, 2:06 PM2019-09-11 14:06:18 (UTC+0)
• ajhalili2006 awarded a token.Sep 29 2019, 7:43 AM2019-09-29 07:43:57 (UTC+0)
• CCicalese_WMF mentioned this in T250406: RFC: Hybrid extension management.Jun 30 2020, 4:10 AM2020-06-30 04:10:33 (UTC+0)
Reedy moved this task from Backlog to Features/Improvements on the Composer board.Feb 2 2021, 2:27 AM2021-02-02 02:27:26 (UTC+0)
Seb35 added a comment.Jul 7 2021, 6:48 PM2021-07-07 18:48:45 (UTC+0)
Comment Actions

Not an ideal solution, but a work-around is to use --dry-run.

For instance you want to install the extension GraphQL and its librairies:

  • you add it with Git or the tarball in extensions/GraphQL,
  • you add "extensions/GraphQL/composer.json" in composer.local.json,
  • you run composer update --no-dev --dry-run
  • If you see that too much extensions/librairies would be updated, you update on a case-by-case (as described above), first with --dry-run, then without:
    • composer update --no-dev --with-dependencies --dry-run webonyx/graphql-php overblog/dataloader-php
    • composer update --no-dev --with-dependencies webonyx/graphql-php overblog/dataloader-php
Esanders subscribed.Dec 7 2021, 3:30 PM2021-12-07 15:30:33 (UTC+0)
Comment Actions

Is there a reason we don't commit composer.lock files? It is recommended that we should: https://getcomposer.org/doc/01-basic-usage.md#commit-your-composer-lock-file-to-version-control

• Samwilson added a comment.Dec 8 2021, 1:22 AM2021-12-08 01:22:22 (UTC+0)
Comment Actions

I think it's because of using the composer-merge plugin, which means MW installations can change composer.lock (by adding to composer.local.json) and so the lock file can't be part of the distribution (i.e. it's bad to change distribution files).

Tgr added a comment.Dec 8 2021, 5:43 AM2021-12-08 05:43:46 (UTC+0)
Comment Actions

In general, using Composer lockfiles isn't really compatible with having a plugin system. We'd have to do something like T167038: Separate "application" and "project" concerns first.

Falloutgen mentioned this in T248925: Make MediaWiki release tarball compatible with PHP 8.0.Jan 29 2022, 2:57 PM2022-01-29 14:57:54 (UTC+0)
Zabe mentioned this in T382882: Special:CheckUser Error: Class "Firebase\JWT\JWT" not found.Jan 2 2025, 12:45 PM2025-01-02 12:45:56 (UTC+0)
Aafi mentioned this in T402730: Error: Class "MediaWiki\OAuthClient\ClientConfig" not found.Aug 24 2025, 9:41 AM2025-08-24 09:41:02 (UTC+0)
Jonathan3 subscribed.Sep 27 2026, 4:19 PM2026-09-27 16:19:29 (UTC+0)
Comment Actions

Is there any update on this? I stick to Mediawiki LTS versions, so don't feel able to install any extensions that require composer. I'm just concerned it might break things. Thanks.

Log In to Comment
Content licensed under Creative Commons Attribution-ShareAlike (CC BY-SA) 4.0 unless otherwise noted; code licensed under GNU General Public License (GPL) 2.0 or later and other open source licenses. By using this site, you agree to the Terms of Use, Privacy Policy, and Code of Conduct. · Wikimedia Foundation · Privacy Policy · Code of Conduct · Terms of Use · Disclaimer · CC-BY-SA · GPL · Credits
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.