0

Let's say I work in a group and somebody else did composer update and pushed changed composer.lock file. I pulled it and now I have to do update too, to match the files from changed lock file.

In symfony I would delete vendor dir and run composer install. But in drupal not all files are in vendor dir.

What is the best workflow in this case? Should I manually delete old vendor files (what dirs exactly?) or there is some composer command that will do all the work for me - check current vendor files with versions from composer.lock file and update what has to be updated?

7
  • can't you just do a composer update too and because of the lock file you'll get the same versions as the other person. composer should hopefully handle any package upgrades/downgrades to match the lock file
    – Leigh
    Commented Oct 23, 2019 at 14:16
  • 1
    @Hudri if everything is into composer and I have updated composer.lock file what command should I executed to update my local vendor files to the same versions as in composer.lock file. I think that calling "composer update" will not look composer.lock but updates to the newest allowed in composer.json
    – MilanG
    Commented Oct 24, 2019 at 7:33
  • 2
    I usually run composer install, AFAIK only install guarantees the exact same set of code on every instance. update does not guarantee the same set of code (mostly it will result in the same, but it might also deliver newer versions if allowed in composer.json)
    – Hudri
    Commented Oct 24, 2019 at 7:36
  • 1
    @Hudri so if someone else on project does "composer update" and then gives me modified composer.lock file I have to run "composer install" and we will both have the same versions of vendor files? Right?
    – MilanG
    Commented Oct 24, 2019 at 7:42
  • 2
    Yes, that's the point of the lock file
    – Hudri
    Commented Oct 24, 2019 at 7:58

1 Answer 1

1

In symfony I would delete vendor dir and run composer install. But in drupal not all files are in vendor dir.

What is the best workflow in this case? Should I manually delete old vendor files (what dirs exactly?)

See .gitignore in your project dir:

# Ignore directories generated by Composer
/drush/contrib/
/vendor/
/web/core/
/web/modules/contrib/
/web/themes/contrib/
/web/profiles/contrib/
/web/libraries/

In case you want to do a fresh start with composer install you can delete all files with:

git clean -fdx .

See https://www.git-scm.com/docs/git-clean/1.7.0

2
  • Ok, but main question here is do I have to delete those files manually or running "composer install" will make sure that all my vendor files are up to date with composer.lock file? I don't want fresh start - I want the simplest way to update vendor files after composer.lock file has been changed (by someone else on the project).
    – MilanG
    Commented Oct 24, 2019 at 8:04
  • My answer is about the hypothetical question "In symfony I would delete vendor ...", if you need to do something similar in Drupal. But normally you don't need a fresh start every time composer.lock has changed.
    – 4uk4
    Commented Oct 24, 2019 at 9:46

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.