0

At our company we have several sites that appear to have been made using the now deprecated method of composer create-project drupal/drupal. We've been fine using previously documented methods to remove the replace block in composer.json and move the drupal/core require statement to update drupal/core.

However, I'm now running into a strange issue with a very specific Contributed Module that is detecting the `"name": "drupal/drupal" statement and version as 1.0, which then conflicts with dependencies it wants to install. I tried removing the name field since composer docs state it is only required for published packages, but this does not help resolve it.

Some other google results suggest that my drupal core is missing a .git repo that may be required to detect versions? How would I resolve this if it's the case? What else can I try?

Error, caused by composer require drupal/csv_serialization:

  Problem 1
    - remove drupal/drupal No version set (parsed as 1.0.0)|remove drupal/core 8.6.1
    - don't install drupal/core 8.6.1|remove drupal/drupal No version set (parsed as 1.0.0)
    - don't install drupal/core 8.6.1|remove drupal/drupal No version set (parsed as 1.0.0)
    - Installation request for drupal/drupal No version set (parsed as 1.0.0) -> satisfiable by drupal/drupal[No version set (parsed as 1.0.0)].
    - Installation request for drupal/core (locked at 8.6.1, required as ^8.6) -> satisfiable by drupal/core[8.6.1].

composer.json:

{
    "name": "drupal/drupal",
    "description": "Drupal is an open source content management platform powering millions of websites and applications.",
    "type": "project",
    "license": "GPL-2.0-or-later",
    "require": {
        "composer/installers": "^1.0.24",
        "wikimedia/composer-merge-plugin": "^1.4",
        "drupal/core": "^8.6",
        "drush/drush": "^9.4",
        "symfony/http-kernel": "^3.4",
        "symfony/http-foundation": "^3.4"
    },
    "minimum-stability": "dev",
    "prefer-stable": true,
    "config": {
        "preferred-install": "dist",
        "autoloader-suffix": "Drupal8"
    },
    "extra": {
        "_readme": [
            "By default Drupal loads the autoloader from ./vendor/autoload.php.",
            "To change the autoloader you can edit ./autoload.php.",
            "This file specifies the packages.drupal.org repository.",
            "You can read more about this composer repository at:",
            "https://www.drupal.org/node/2718229"
        ],
        "merge-plugin": {
            "include": [
                "core/composer.json"
            ],
            "recurse": true,
            "replace": false,
            "merge-extra": false
        },
        "installer-paths": {
            "core": ["type:drupal-core"],
            "modules/contrib/{$name}": ["type:drupal-module"],
            "profiles/contrib/{$name}": ["type:drupal-profile"],
            "themes/contrib/{$name}": ["type:drupal-theme"],
            "drush/contrib/{$name}": ["type:drupal-drush"],
            "modules/custom/{$name}": ["type:drupal-custom-module"],
            "themes/custom/{$name}": ["type:drupal-custom-theme"]
        }
    },
    "autoload": {
        "psr-4": {
            "Drupal\\Core\\Composer\\": "core/lib/Drupal/Core/Composer"
        }
    },
    "scripts": {
        "pre-autoload-dump": "Drupal\\Core\\Composer\\Composer::preAutoloadDump",
        "post-autoload-dump": "Drupal\\Core\\Composer\\Composer::ensureHtaccess",
        "post-package-install": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup",
        "post-package-update": "Drupal\\Core\\Composer\\Composer::vendorTestCodeCleanup",
        "drupal-phpunit-upgrade-check": "Drupal\\Core\\Composer\\Composer::upgradePHPUnit",
        "drupal-phpunit-upgrade": "@composer update phpunit/phpunit --with-dependencies --no-progress",
        "phpcs": "phpcs --standard=core/phpcs.xml.dist --runtime-set installed_paths $($COMPOSER_BINARY config vendor-dir)/drupal/coder/coder_sniffer --",
        "phpcbf": "phpcbf --standard=core/phpcs.xml.dist --runtime-set installed_paths $($COMPOSER_BINARY config vendor-dir)/drupal/coder/coder_sniffer --"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://packages.drupal.org/8"
        }
    ]
}
  • 2
    This is supposed to help. github.com/grasmash/composerize-drupal – Kevin Nov 20 '18 at 19:37
  • Also try adding "conflict": { "drupal/drupal": "*" }. You may need to change the name of your package to make that work – Clive Nov 20 '18 at 19:38
  • "There are a few tools that attempt to convert your existing Drupal codebase to a Composer-managed codebase (e.g. composerize-drupal, or Drupal Console's composerize command), but I have found them to be a little more trouble than they are worth. I recommend rebuilding the codebase from scratch, like I do in this guide." Source: jeffgeerling.com/blog/2018/… – 4k4 Nov 20 '18 at 20:35
  • @Kevin If you would like to provide you answer with whatever context might be helpful to the next person, I'll accept it, it worked quite well on a minimal site install. It should be noted that more than likely the desired default command would be composer composerize-drupal --no-update, because it also moved me from 8.6.1 to 8.6.3. So I did a git reset --hard and then ran again with that to more preferable results. I prefer to keep my git commits tied to one single intention, so I'll run core updates later. – Aaron Chamberlain Nov 20 '18 at 21:01
  • I haven't actually used it to turn a tarball installed project into a totally composer controlled one, so I am not 100% on the outcome, but I know a colleague at work was able to do it. Did it work for you? – Kevin Nov 20 '18 at 21:13
1

There is a tool that helps convert old style Drupal 8 installs to composer managed ones: https://github.com/grasmash/composerize-drupal

This should help restructure the project to leverage Composer, which the vanilla tarball install is not geared toward.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.