3

This is excerpt from my composer.json file (trimmed for readability). It was created by running composer create-project drupal/drupal my_site_name 8.0.* as described on drupal.org:

{
  "name": "drupal/drupal",
  "type": "project",
  "require": {
    "composer/installers": "^1.0.21",
    "wikimedia/composer-merge-plugin": "^1.3.0"
  },
  "replace": {
    "drupal/core": "~8.0"
  },
  "minimum-stability": "dev",
  "prefer-stable": true,
  "extra": {
    "merge-plugin": {
      "include": [
        "core/composer.json"
      ],
      "recurse": false,
      "replace": false,
      "merge-extra": false
    }
  }
}
  1. If I just do composer update - core is not updated, only packages inside vendor dir.
  2. If in addition to the above, I update my composer.json file and replace core version with ~8.1 - still core not affected.

The only thing that worked for me was to:

  1. Remove core dir, vendor and composer.lock.
  2. Edit composer.json and:
    1. Remove replace section.
    2. Add "drupal/core": "~8.1" to require section.
  3. Run composer install.

That worked however every installed package complained that:

Class Drupal\Core\Composer\Composer is not autoloadable, can not call post-package-install script

So I'm not sure if the whole process completed flawlessly. Also removing core directory seems like a desperate move.

What is the recommended procedure of updating core to the next minor version with composer (for example 8.0 => 8.1)? Note that I am not using drupal-composer as suggested in this answer.

Update 1

After trying to use composer require --update-with-dependencies "drupal/core:8.1.*" I got no results:

$ composer create-project drupal/drupal my_site_name 8.0.*
Installing drupal/drupal (8.0.6)
  - Installing drupal/drupal (8.0.6)
    Cloning c5afca05cde0c94ef4d7aff5b078be27024670d2

Created project in my_site_name
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Nothing to install or update
Generating autoload files
> Drupal\Core\Composer\Composer::preAutoloadDump
> Drupal\Core\Composer\Composer::ensureHtaccess
Do you want to remove the existing VCS (.git, .svn..) history? [Y,n]? Y
$ cd my_site_name/
$ composer require --update-with-dependencies "drupal/core:8.1.*"
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Nothing to install or update
Writing lock file
Generating autoload files
> Drupal\Core\Composer\Composer::preAutoloadDump
> Drupal\Core\Composer\Composer::ensureHtaccess

I'm using composer version 1.1-dev.

1
  • I think if you want to use Composer to update core, then you should follow drupal-composer. Otherwise, use Git or drush and composer update.
    – mradcliffe
    Apr 18, 2016 at 20:24

1 Answer 1

6

I see, you directly get drupal/drupal. I don't think that's actually supported, you still get a vendor folder from git and the composer.json isn't properly set up. I'm using composer command from this site:

composer create-project drupal-composer/drupal-project:8.x-dev myproject --stability dev --no-interaction

Regarding update, the trick seems to be the following argument to composer require:

composer require --update-with-dependencies "drupal/core:8.1.*"

That updated drupal/core and all dependencies it has.

11
  • This command added drupal/core:8.1.* to composer.json file inside require section and returned Nothing to install or update. After that when I ran composer update only vendor dir got updated, but not core. Apr 19, 2016 at 11:25
  • I tested this, it worked perfectly fine for me for updating from a drupal-project on 8.0.6 to 8.1.0-rc1. Maybe your previous testing messed something up. try it on a clean install and if that works, try to figure out what you already have changed and what's confusing it.
    – Berdir
    Apr 19, 2016 at 11:33
  • That's what I'm doing - I'm testing this with clean install. Please have a look at my update to the question. I've pasted commands and output that I got. Apr 19, 2016 at 11:45
  • 1
    I see, you directly get drupal/drupal. I don't think that's actually supported, you still get a vendor folder from git and the composer.json isn't properly set up. I'm using "composer create-project drupal-composer/drupal-project:8.x-dev myproject --stability dev --no-interaction" from bojanz.wordpress.com/2015/09/18/d8-composer-definitive-intro. Works fine there.
    – Berdir
    Apr 19, 2016 at 19:49
  • 1
    Well, I'm using a method provided on drupal.org. I expected that to be more accurate :) Apr 19, 2016 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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