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

Comments

sdstyles created an issue. See original summary.

sdstyles’s picture

sdstyles’s picture

Status: Active » Needs review

See attached patch.

sdstyles’s picture

Issue summary: View changes
weri’s picture

I 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".

weri’s picture

Status: Needs review » Reviewed & tested by the community

I reviewed the patch and it fixes the problem with the wrong dependency.

tobiasb’s picture

This patch removes also the composer.json.

tobiasb’s picture

Title: Downloading module with composer requires wrong dependency » Remove composer.json and namespace dependencies
mike.davis’s picture

Status: Reviewed & tested by the community » Needs review

This 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:

    "replace": {
        "drupal/link-link": "*"
    },
sdstyles’s picture

How you applied the patch?

mike.davis’s picture

Status: Needs review » Reviewed & tested by the community

Arh 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

heddn’s picture

Status: Reviewed & tested by the community » Needs work

Don't delete the composer.json, just update it to use 'drupal/link', 'drupal/views'. No need to update info.yml

heddn’s picture

At 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.

pingers’s picture

Thanks for figuring this out! I returned from vacation and found link-link module in my project... doh!

tobiasb’s picture

We do not need the composer.json, because the repository provides all informations which are necessary for composer.

ndf’s picture

  1. +++ b/composer.json
    @@ -4,5 +4,7 @@
    +  "require": {
    +    "drupal/core": "~8"
    +  }
    

    Guess 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

  2. +++ b/redirect.info.yml
    @@ -5,5 +5,5 @@ core: 8.x
    + - drupal:link
    + - drupal:views
    

    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

heddn’s picture

Issue summary: View changes
Issue tags: -Needs issue summary update

re #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.

ndf’s picture

Status: Needs review » Reviewed & tested by the community

#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

heddn’s picture

Title: Remove composer.json and namespace dependencies » Update composer.json and namespace module dependencies

Title update

agoradesign’s picture

It 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!

heddn’s picture

Priority: Normal » Critical

+1 on #20. Currently this module is un-installable via composer. Bumping priority.

agoradesign’s picture

My 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:

  "repositories": [
    {
      "type": "package",
      "package": {
        "name": "drupal/link-link",
        "description": "this is just a workaround, until redirect's info is fixed because link module's 8.x branch was deleted",
        "version": "master",
        "type": "library",
        "dist": {
          "url": "https://github.com/unclebob/empty/archive/master.zip",
          "type": "zip"
        }
      }
    },
    {
      "type": "composer",
      "url": "https://packages.drupal.org/8"
    }
  ],
acbramley’s picture

Marked #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:

   "replace": {
	    "drupal/link-link": "*"
    },

To your composer file if you don't want to apply a patch.

agoradesign’s picture

oh yes, haven't thought of "replace". Of course this is way better!

Berdir’s picture

Can 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).

Mixologic’s picture

I have rebuilt all the project dependencies and composer metadata files for redirect as well as all other projects that inherited that issue.

Lukas von Blarer’s picture

The patch works perfect. Lets get this committed!

RajabNatshah’s picture

+1 Testing ........

RajabNatshah’s picture

Are we all switching to use the namespace?
Profiles, Modules, Features.

 dependencies:
   drupal:link
   drupal:views
mlncn’s picture

A 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

Berdir’s picture

See #25 and #26, if you clear your composer cache then it should just work, without requiring this patch.

dobrzyns’s picture

I 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.

acbramley’s picture

I ran composer update drupal/redirect yesterday after the fixes to the composer repos as stated in #25/#26 and it fixed it.

RajabNatshah’s picture

This 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 :)

Lukas von Blarer’s picture

Could we get this committed? Currently installing using composer fails...

Mixologic’s picture

@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.

Berdir’s picture

Priority: Critical » Major
Status: Reviewed & tested by the community » Fixed

Yeah, 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 ;)

  • Berdir committed a6167de on 8.x-1.x authored by heddn
    Issue #2795709 by heddn: Update composer.json and namespace module...
johnnny83’s picture

I'm a little bit confused now... What do I have to do finally to get rid of the drupal/link-link? :D

acbramley’s picture

@johnnny83 see #36

johnnny83’s picture

I did this, but I still have drupal/link-link in my composer.lock

Mixologic’s picture

@johnny83 - can you do acomposer -vvv why drupal/link-link and post the results here?

johnnny83’s picture

I'm not so sure if this is any help...

Reading ./composer.json
Loading config file ./composer.json
Checked CA file C:\Users\xxx\AppData\Local\Temp\composer-cacert-xxxxxxxxxxxxxxxxx.pem: valid
Executing command (C:\Users\xxx\Internet\project): git branch --no-color --no-abbrev -v
Failed to initialize global composer: Composer could not find the config file: C:/Users/xxx/AppData/Roaming/Composer/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
Reading C:\Users\xxx\Internet\project/vendor/composer/installed.json
Loading plugin DrupalComposer\DrupalScaffold\Plugin
Loading plugin Composer\Installers\Plugin
Loading plugin cweagans\Composer\Patches
Running 1.2.2 (2016-11-03 17:43:15) with PHP 5.6.19 on Windows NT / 6.1
Mixologic’s picture

@johnnny83 you have to run all of your composer commands from the root directory of your project, where your root composer json resides.

johnnny83’s picture

That'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"

johnnny83’s picture

I 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?

Mixologic’s picture

how about composer remove link-link ?

johnnny83’s picture

Yeah, 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...

drupal/link-link is not required in your composer.json and has not been removed
> DrupalProject\composer\ScriptHandler::checkComposerVersion
Dependency "drupal/core" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Dependency "drupal/core" is also a root requirement, but is not explicitly whitelisted. Ignoring.
Loading composer repositories with package information
Updating dependencies (including require-dev)
Deleting web/modules/contrib/link-link - deleted
Writing lock file
Generating autoload files
> DrupalProject\composer\ScriptHandler::createRequiredFiles

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.