Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
I'm using Composer as package manager for contrib modules, requiring and installing redirect module, composer is fetching one wrong dependency drupal/link-link
From redirect.info.yml
I see that module dependencies are:
dependencies:
- link
- views
So composer downloads as dependency Link project, but real dependency is Core Link module.
I don't know why it's not happening for views dependency.
Proposed resolution
Change dependencies namespace to reflect that project dependencies are Core modules and not contrib projects.
Update composer.json to list drupal 8 as a dependency.
drupal:link
Comment | File | Size | Author |
---|---|---|---|
#13 | redirect-composer_json-2795709-13.patch | 535 bytes | heddn |
Comments
Comment #2
sdstyles CreditAttribution: sdstyles at FFW commentedComment #3
sdstyles CreditAttribution: sdstyles at FFW commentedSee attached patch.
Comment #4
sdstyles CreditAttribution: sdstyles at FFW commentedComment #5
weri CreditAttribution: weri at Previon Plus AG commentedI created a patch which can be used as a patch in an existing project which is built with composer. This patch is only usable for "8.x-1.0-alpha1".
Comment #6
weri CreditAttribution: weri at Previon Plus AG commentedI reviewed the patch and it fixes the problem with the wrong dependency.
Comment #7
tobiasbThis patch removes also the composer.json.
Comment #8
tobiasbComment #9
mike.davis CreditAttribution: mike.davis commentedThis patch still downloads 'drupal/link-link' module when doing a 'composer update' so it doesn't seem to remove this dependancy.
Adding the following worked for me:
Comment #10
sdstyles CreditAttribution: sdstyles at FFW commentedHow you applied the patch?
Comment #11
mike.davis CreditAttribution: mike.davis commentedArh sorry ... that would have been helpful :).
I have been using composer to add modules to a site using 'composer require drupal/redirect' for instance. Within the composer file you can then specify the patches to apply to specific modules.
Looking into this a bit further, it seems that the module and its dependancies are downloaded before the patch is applied, so actually this patch is not getting a chance to be applied before the modules dependancies are downloaded.
It makes testing this difficult in this scenario, but once this patch has been confirmed as working and a release have been created with this in it then using composer should correctly again.
I'll change the status back as my issue here is down to composer rather than the patch it seems
Comment #12
heddnDon't delete the composer.json, just update it to use 'drupal/link', 'drupal/views'. No need to update info.yml
Comment #13
heddnAt this point, this isn't really testable since the only way to test it is by applying the composer changes and wait for things to deploy to the packagist environment. However, this follows the same pattern used in many other contrib projects. See media_entity or migrate_source_csv as example. Once the un-official packagist goes away, we could probably also put the drupal/link, etc into composer.json, but the versions patterns are entirely different between un-official so for now leaving the versions out is probably fine.
Comment #14
pingers CreditAttribution: pingers as a volunteer and at University of Adelaide commentedThanks for figuring this out! I returned from vacation and found link-link module in my project... doh!
Comment #15
tobiasbWe do not need the composer.json, because the repository provides all informations which are necessary for composer.
Comment #16
ndf CreditAttribution: ndf at Dx Experts commentedGuess this should be "~8.0"
@see https://getcomposer.org/doc/articles/versions.md#tilde
Drupal Commerce requires core 8.2 or higher, they use "~8.2" in the composer file. @see http://cgit.drupalcode.org/commerce/tree/composer.json?h=8.x-2.x
This is also used in other projects and should fix the issue with downloading the link dependency.
http://cgit.drupalcode.org/commerce/tree/commerce.info.yml?h=8.x-2.x
http://cgit.drupalcode.org/metatag/tree/metatag.info.yml?h=8.x-1.x
http://cgit.drupalcode.org/pathauto/tree/pathauto.info.yml
Added tag "Needs issue summary update".
The patch improves both the composer.json and the info.yml
This serves multiple goals, one is fixing the unwanted download of the https://www.drupal.org/project/link when using
compose require drupal/redirect
Comment #17
heddnre #16:
#1: redirect doesn't have any specific core requirements, so "~8" is just fine.
#2: not sure if you are plus +1 on the patch in #13 or wanting some additional work here. Please be more clear.
#3: What is needed in the issue summary? It seems fairly clear to me. I made some small tweaks to it just now, but if there are specific things missing, please add them into the summary.
And with all the feedback since #13, can someone just review and mark this RTBC (or needs work)? Reviews without either of those changes are just extra noise.
Comment #18
ndf CreditAttribution: ndf at Dx Experts commented#16
#1: ok perfect
#2: yes +1
#3: I didn't understand the issue-title initially. What do you think of "Fix module dependency declaration (drupal-core/link) for usage with composer workflow"? This can be done on commit.
So RTBC
Comment #19
heddnTitle update
Comment #20
agoradesign CreditAttribution: agoradesign commentedIt seems, this becomes rather urgent. While until now, there was this harmless download, now we face a problem: it seems, that the link (contrib) module has removed its 8.x branch. Theoretically that should help in behaving the same way the Views dependency does, that it is resolved to the core module. Unfortunately this is not the case. Composer still tries to load drupal/link-link, which simply does not exist anymore! I've already cleared my Composer cache, so it seems that the info still comes via Composer endpoint...
So please commit this!
Comment #21
heddn+1 on #20. Currently this module is un-installable via composer. Bumping priority.
Comment #22
agoradesign CreditAttribution: agoradesign commentedMy workaround is re-defining the drupal/link-link package in the "repositories" section of composer.json to trick composer.
Basically you can choose any file/project to download, as it does not really matter, what's getting downloaded. You have to ensure that you insert the code before the Drupal Composer endpoint.
Interestingly, I've found an empty repository on Github, which I perceived as a good candidate for that... So this is what my repositories section looks like:
Comment #23
acbramley CreditAttribution: acbramley commentedMarked #2802707: Modules with link as a dependency add drupal/link-link as composer requirement as a duplicate. It seems people have had success with adding:
To your composer file if you don't want to apply a patch.
Comment #24
agoradesign CreditAttribution: agoradesign commentedoh yes, haven't thought of "replace". Of course this is way better!
Comment #25
BerdirCan confirm that the replace works.
I also just talked to Mixologic, and he fixed the redirect composer information on d.o to no longer include that dependency. So if you clear your composer caches now and try again then it should work, without any special tricks (Does not mean that we shouldn't commit this patch).
Comment #26
MixologicI have rebuilt all the project dependencies and composer metadata files for redirect as well as all other projects that inherited that issue.
Comment #27
Lukas von BlarerThe patch works perfect. Lets get this committed!
Comment #28
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot commented+1 Testing ........
Comment #29
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot commentedAre we all switching to use the namespace?
Profiles, Modules, Features.
Comment #30
mlncn CreditAttribution: mlncn at Agaric for Teachers with GUTS, MASS Design Group commentedA release with this patch now would help a great deal, as builds are now failing due to Redirect's phony requirement— http://data.agaric.com/saga-drupal-link-link
Comment #31
BerdirSee #25 and #26, if you clear your composer cache then it should just work, without requiring this patch.
Comment #32
dobrzyns CreditAttribution: dobrzyns commentedI tried clearing the composer cache with
composer clearcache
, and that did not resolve the issue for me.The patch applies successfully and resolves the issue.
I second that it would be extremely helpful that this is committed and a new release cut, especially as the issue is critical since it breaks builds.
Comment #33
acbramley CreditAttribution: acbramley commentedI ran composer update drupal/redirect yesterday after the fixes to the composer repos as stated in #25/#26 and it fixed it.
Comment #34
Rajab Natshah CreditAttribution: Rajab Natshah at Vardot commentedThis is the issue with Many Ships delivering one delivery package.
The composer need a delivery manager to build the package on the Software Delivery Manager
It's like the App development manager and the real App production manager
I hope that we start to have the composer builder right out from Drupal.org site.
Or we could have Composer Managers which they are allowed to have there set of Public and Private packages right out from their Drupal.org account.
A private
https://packagist.org
With this code:
https://github.com/composer/packagist
It's a bit like private packagist and composer hosting for registered companies.
Thank you :)
Comment #35
Lukas von BlarerCould we get this committed? Currently installing using composer fails...
Comment #36
Mixologic@Lukas you should not need this patch. Currently installing via composer does not fail in any of the tests I have ran. Run
composer cacheclear
to clear out any erroneous metadata, and then try and require drupal/redirect.If that does not work, please paste the results of your require statement with -vvv. ex:
composer -vvv require drupal/redirect
@RajabNatshah - we already have a private packagist for composer, thats what https://packages.drupal.org is.
Comment #37
BerdirYeah, I think this isn't critical anymore but still makes sense to get it in.
And since I'm officially a co-maintainer as of today, I can now also commit it ;)
Comment #39
johnnny83 CreditAttribution: johnnny83 commentedI'm a little bit confused now... What do I have to do finally to get rid of the drupal/link-link? :D
Comment #40
acbramley CreditAttribution: acbramley commented@johnnny83 see #36
Comment #41
johnnny83 CreditAttribution: johnnny83 commentedI did this, but I still have drupal/link-link in my composer.lock
Comment #42
Mixologic@johnny83 - can you do a
composer -vvv why drupal/link-link
and post the results here?Comment #43
johnnny83 CreditAttribution: johnnny83 commentedI'm not so sure if this is any help...
Comment #44
Mixologic@johnnny83 you have to run all of your composer commands from the root directory of your project, where your root composer json resides.
Comment #45
johnnny83 CreditAttribution: johnnny83 commentedThat's what I did.
When I use the command just with two v's (-vv) there are no errors, just this message:
There is no installed package depending on "drupal/link-link"
Comment #46
johnnny83 CreditAttribution: johnnny83 commentedI checked the composer.json of the Redirect Module and also redirect.info.yml and they already look like the patch should make them look. So can't I just delete the link-link part manually in the root composer.lock?
Comment #47
Mixologichow about
composer remove link-link
?Comment #48
johnnny83 CreditAttribution: johnnny83 commentedYeah, I finally got rid of it with
composer remove drupal/link-link
, thank you!Although it showed some warnings, but I hope this doesn't matter...