Problem/Motivation
tl;dr: Not only does Pathauto require Ctools despite not actually depending on it, it provides a workaround that's not appropriate for project templates like Starshot. A different solution would be preferable.
I'm not the first person (or the seventh) to point out that Pathauto declares a Composer dependency on Ctools even though it doesn't use it at all. (See previous issues below.) And I realize a workaround has been provided. But that workaround, involving the use of Composer's replace feature, is not appropriate for project templates where making that decision for users ahead of time would result in a very confusing situation if they ever try to composer require drupal/ctools and it does nothing. This is especially true for Starshot, which will be the recommended starting point for all new sites, and by extension a lot of users who 1) don't want unused code in production and 2) aren't necessarily experienced with Composer.
Downstream issue in Starshot
Previous issues
- #2669304: Any chance of dropping CTools as dependency? (15 Feb 2016)
- #3222775: Remove dependency on CTools (8 Jul 2021)
- #3325473: Require drupal/ctools (6 Dec 2022)
- #3339998: Remove ctools dependency (7 Feb 2023)
- #3361103: Composer dependency on ctools not needed (17 May 2023)
- #3387793: Remove ctools requirement from composer.json (17 Sep 2023)
- #3454336: Remove the ctools dependency if it's not needed (13 Jun 2024)
- #3574073: drupal/pathauto 1.14.0 requires drupal/ctools (*) (17 feb 2026)
Proposed resolution
The most obvious solution would probably be to remove the dependency and bump the module version. It probably wouldn't be a bad time to move to semver anyway. If not, and your still worried about the undeclared dependency problem, perhaps you could remove the dependency and use a message in an update hook and/or admin notice.
Comments
Comment #2
traviscarden commentedComment #3
traviscarden commentedComment #4
ressaThanks for pursuing this @TravisCarden. Streamlining the Starshot experience is a great incentive to getting the Ctools module issue sorted out, and removed from Pathauto.
Comment #5
berdirHaving a module in the code base that's not enabled is a minor annoyance at best, you'll have plenty of non-enabled modules in the code base.
Some of the previous issues are the ones where the actual work happened, yes, there have been 4-5 issues asking about this, but nothing was broken due to that, it's just low prio questions. Removing it is likely going to confuse dozens to hundreds of less experienced users that will get actual warnings and problems when upgrading. Pathauto has 300k installations on D8, and getting such an issue every few months is a price I'm happy to pay to avoid the alternative scenario.
Yes, a 2.x release will then remove it, but I have no plans to create that any time soon and I won't do it only for that. ctools is still actively maintained and has a D11 compatible stable release already, so it doesn't block D11 adoption either. If that ever changes then I might push for the removal to happen but until then, this likely won't happen.
Comment #6
traviscarden commentedThanks, @Berdir. Your position is perfectly understandable. I will share as a matter of documentation, that the biggest reason I care about unused code in production is that I've had to rush deployments before for security vulnerabilities in modules I wasn't using and didn't have installed, and that, of course, is a risk a prefer to avoid. But as I say, I respect your position, and I thank you for your work on such a critical module. 🙂
Comment #7
anthonytm commentedFor folks stumbling across this issue, there is a simple fix until the next major version is released. If you are sure you do not need ctools in your project, simply add the following replace in your project composer.json file:
That will fully remove ctools. Again, make sure you aren't using for anything else. This solution is provided in the release notes that are referenced on the main project page.
Comment #8
anybodyJust ran into this and looking forward to a 2.x release in the future without the old ctools dependency in composer, which is indeed also confusing.
Comment #9
mably commentedComment #10
romulasry commentedUpdate?
Comment #11
o'briatI understand Berdir concerns, but peoples using ctools without specifically require it should be noticed or nothing will never change.
Why not using the
hook_requirement sto do it (there's maybe better way? Via composer?):A check of the composer.json could be added to avoid false positif