0

I have several packages under vendor which are version-controlled with Git. The packages are registered at Packagist and are referenced in other packages or the main composer.json with version expressions like ~1.0.

When I run composer update --prefer-source, Composer leaves the Git-controlled packages alone and updates only all “external” dependencies, if available. This is expected behaviour.

However: When I create a tag of a package (which Packagist correctly treats as a new version), composer update --prefer-source removes the Git-controlled package and installes a non-Gitted one.

How can I prevent Composer from replacing recently tagged packages during updates? Or is this a bug in Composer?

lxg
  • 12,375
  • 12
  • 51
  • 73
  • It sounds uncommon to me. Composer usually did stick with what it downloaded first. If that was a repo, fetching and checking out a new tag would be faster than deleting and downloading a ZIP. Can you post a short command sequence to reproduce that problem? And you should state the version of Composer you are using. – Sven Feb 22 '17 at 19:49
  • @Sven: What do you mean by “command sequence”? My Composer version is 1.3.2. – lxg Feb 22 '17 at 20:47
  • Could it have to do with the Git configuration of these packages? There’s nothing special there, but maybe there’s something missing? – lxg Feb 22 '17 at 20:51
  • How can I reproduce the problem on my own machine? Can you try to create a small example that is easy to reproduce, like creating an new, empty project, adding one package as Git repo, then updating the way you do, and see if the problem is still there? That's what I was referring to with "command sequence". – Sven Feb 23 '17 at 23:38
  • After giving this some thought, I think your first comment helped me: “*Composer usually did stick with what it downloaded first.*” I cleared the composer cache and reinstalled my packages with `composer require vendor/package --prefer-source`. Now composer does no longer replace the package after tagging. However, it is detached `HEAD detached at `. But that can be simply fixed with `git checkout `. (If you want, you can post this as answer, to collect unicorn points.) – lxg Feb 24 '17 at 09:29

0 Answers0