By RominRonin


2017-02-01 10:09:53 8 Comments

I'm very new to composer, I've only used it to install the occasional necessary library for our D8 projects. At each Drupal update I normally run

drush up drupal

Which (among other things) replaces the vendor folder and composer.json, so on sites with library dependencies, I need to re-run

composer require [library]

Aware of the touted benefits of Composer as a dependency manager, I want to use composer to maintain our Drupal projects. However I've run into issues, namely that

composer update

or composer update drupal/core --with-dependencies both give me "Nothing to install or update". After some reading, I found this resource https://github.com/drupal-composer/drupal-project. With this unzip, if I run

composer install

I get the correct latest version of Drupal installed in ./web. But when I use the yaml from the template composer.json file in my own composer.json file I still get "Nothing to install or update".

My folder structure is identical to the .zip distribution, so /core and /vendor and /sites etc are all in the same folder, so I have obviously adjusted the composer.json file according. But it doesn't matter what I do, I just get "Nothing to install or update" "Nothing to install or update" "Nothing to install or update"

So, I'm beginning to think that composer update with or without dependencies REQUIRES YOU TO HAVE INSTALL THE DRUPAL 8 PROJECT WITH COMPOSER TO BEGIN WITH.

Is that right? If so, then I can move on. If not then I need to know what I'm doing wrong. Right now it's not a big deal and I can manage the update process, but it seems each new project requires more and more non-core libraries, so I know composer will save me a lot of time in the future.

TL;DR - Can someone give me a kickstart to configuring my EXISTING, WORKING PRODUCTION SITES so I can use composer to update them, the usual ReadMe's don't seem to work properly with sites that weren't also installed with composer.

1 comments

@RominRonin 2017-02-01 11:03:54

I got this working, I was very close but removing /vendor and composer.lock was what helped in the end. Here are the steps from the top:

  1. add the line "drupal/core": "~8.1" to the 'require' statement (or update it to whatever version you require - in my case ^8.0 - latest Drupal 8 release).
  2. Remove the drupal/core line from the 'replace' statement.
  3. Add the following line somewhere (at the end? I believe this should replace the existing repositories statement, more information here. ):

    "repositories": { 
        "drupal": {
            "type": "composer",
            "url": "https://packages.drupal.org/8" 
        }
    }
    
  4. Remove the /vendor folder

  5. Remove the composer.lock file
  6. Run your core update as follows

    composer update drupal/core --with-dependencies
    

@mradcliffe 2017-02-01 13:30:05

You can add a repository via the command-line by running composer config repositories.drupal composer https://packages.drupal.org/8. Also if you are managing everything with composer you can start doing composer require drupal/<modulename> instead of manually modifying composer.json. Also, running composer update will update your composer.lock file so you don't need to delete it. If you're using Drupal 8.0.x, then you can't really manage things with composer without composer manager.

@mpdonadio 2017-02-01 14:25:29

@mradcliffe I recently converted a D8 site from drush management to composer management. Nuking compsoser.lock did seem to be a necessary step (still don't know why) to get this to work.

@mpdonadio 2017-02-01 14:28:00

Two notes. Personally, I like to pin core to a precise version so I am never surprised (eg,"drupal/core": "8.2.5",) to prevent update hook surprises. Also, adding the extra section from the page you reference ensures modules/themes/etc end up where you want them.

@mradcliffe 2017-02-01 14:30:54

The drupal-merge-plugin might help with not having to delete vendor or the lock file. I use that to bridge the gap between drush make and composer since I have some problems with using composer directly.

@RominRonin 2017-02-02 14:43:15

Once I get the hang of what the correct yaml is, I'll look into the correct composer commands. Thanks mradcliffe

@RominRonin 2017-02-02 14:44:17

@mpdonadio - I would assume that modules and themes just automatically go to /modules and /themes, no?

@RominRonin 2017-02-02 14:45:26

@mradcliffe - 8.2.6 was released yesterday, and I didn't need to remove .lock or /vendor to update, 'composer update drupal/core --with-dependencies' worked as expected.

@mpdonadio 2017-02-02 15:21:29

@RominRonin Only when you specify the locations, drupal.org/node/2718229

@Sébastien Gicquel 2018-03-16 08:22:08

If only i had found your answer before. I’ve struggled hours to find a solution. Do I have to change this manually each time I want to update or was it an issue with composer.json ?

Related Questions

Sponsored Content

2 Answered Questions

[SOLVED] composer update drupal/drupal does not work : Nothing to install or update

  • 2018-03-15 10:13:47
  • Sébastien Gicquel
  • 2343 View
  • 2 Score
  • 2 Answer
  • Tags:   8 updating composer

5 Answered Questions

[SOLVED] What is the correct composer based core update workflow?

1 Answered Questions

[SOLVED] Why doesn't core get updated to 8.5?

  • 2018-04-10 19:15:21
  • ARMANDO SILVA
  • 218 View
  • 2 Score
  • 1 Answer
  • Tags:   updating composer

0 Answered Questions

How to force composer to use its installed version in drupal-project?

  • 2018-03-05 18:31:05
  • nigelwhite
  • 109 View
  • -1 Score
  • 0 Answer
  • Tags:   composer

1 Answered Questions

[SOLVED] Drupal 8 update via drush removes files from vendor folder

  • 2018-02-23 10:09:03
  • user3086053
  • 278 View
  • 0 Score
  • 1 Answer
  • Tags:   8 updating composer

2 Answered Questions

[SOLVED] Updating Drush with Composer

  • 2016-12-05 15:09:08
  • iain-g
  • 7824 View
  • 3 Score
  • 2 Answer
  • Tags:   drush composer

1 Answered Questions

[SOLVED] Do not install core when installing modules with composer

  • 2017-11-09 19:45:58
  • Maxim Neaga
  • 133 View
  • -1 Score
  • 1 Answer
  • Tags:   composer

4 Answered Questions

[SOLVED] Updating core from 8.2 to 8.3 via composer

  • 2017-04-18 13:54:14
  • Rob Holmes
  • 4883 View
  • 9 Score
  • 4 Answer
  • Tags:   8 updating composer

1 Answered Questions

[SOLVED] How do I create a module that uses composer to manage a 3rd party library?

  • 2017-01-15 09:55:18
  • Jaypan
  • 176 View
  • 3 Score
  • 1 Answer
  • Tags:   8 composer

0 Answered Questions

Running drupal composer-update no longer works

  • 2017-01-16 20:03:25
  • RaisinBranCrunch
  • 330 View
  • 0 Score
  • 0 Answer
  • Tags:   8 composer

Sponsored Content