composer / composer

Dependency Manager for PHP
https://getcomposer.org/
MIT License
28.57k stars 4.54k forks source link

running composer - keep installing and uninstalling packages #1030

Closed marcos-abreu closed 12 years ago

marcos-abreu commented 12 years ago

If I run consecutively the command: composer update. It keep installing and uninstalling packages I have listed on my composer.json file - I would think that if the package has the most current version it shouldn't be touched.

here is my composer.json

{
    "require": {
        "silex/silex": "1.0.*",
        "symfony/monolog-bridge": "2.1.*",
        "symfony/twig-bridge": "2.1.*",
        "monolog/monolog": ">=1.0.0,<1.2-dev",
        "twig/twig": ">=1.2.0,<2.0-dev"
    },
    "minimum-stability": "dev"
}

here is the ouptup:

dev@vm:~/web/application$ ./composer.phar update
Loading composer repositories with package information
Updating dependencies
  - Installing symfony/twig-bridge (dev-master de73f8)
    Cloning de73f89daeb3ea77d48dee538f3933f9567cd2be

  - Removing symfony/symfony (dev-master)
  - Updating symfony/symfony dev-master (e706e8 => d1be45)
    Checking out d1be451996e714afe65acd5d1ac946f10e96d46d

  - Updating symfony/symfony dev-master (d16a85 => d1be45)
    Checking out d1be451996e714afe65acd5d1ac946f10e96d46d

symfony/twig-bridge suggests installing symfony/form (dev-master)
symfony/twig-bridge suggests installing symfony/templating (dev-master)
symfony/twig-bridge suggests installing symfony/translation (dev-master)
symfony/twig-bridge suggests installing symfony/yaml (dev-master)
symfony/twig-bridge suggests installing symfony/security (dev-master)
Writing lock file
Generating autoload files
dev@vm:~/web/application$ ./composer.phar update
Loading composer repositories with package information
Updating dependencies
  - Installing symfony/http-foundation (dev-master e706e8)
    Cloning e706e8673fc139de5d1ee4d2f2b8998d23e852b5

  - Installing symfony/routing (dev-master d16a85)
    Cloning d16a85b229a7a01790998ad6bf66142860c3de5b

  - Removing symfony/twig-bridge (dev-master)
  - Installing symfony/symfony (dev-master d1be45)
    Cloning d1be451996e714afe65acd5d1ac946f10e96d46d

symfony/routing suggests installing symfony/config (dev-master)
symfony/routing suggests installing symfony/yaml (dev-master)
symfony/routing suggests installing doctrine/common (>=2.2,<2.4-dev)
Writing lock file
Generating autoload files
dev@vm:~/web/application$ ./composer.phar update
Loading composer repositories with package information
Updating dependencies
  - Installing symfony/twig-bridge (dev-master de73f8)
    Cloning de73f89daeb3ea77d48dee538f3933f9567cd2be

  - Removing symfony/symfony (dev-master)
  - Updating symfony/symfony dev-master (e706e8 => d1be45)
    Checking out d1be451996e714afe65acd5d1ac946f10e96d46d

  - Updating symfony/symfony dev-master (d16a85 => d1be45)
    Checking out d1be451996e714afe65acd5d1ac946f10e96d46d

symfony/twig-bridge suggests installing symfony/form (dev-master)
symfony/twig-bridge suggests installing symfony/templating (dev-master)
symfony/twig-bridge suggests installing symfony/translation (dev-master)
symfony/twig-bridge suggests installing symfony/yaml (dev-master)
symfony/twig-bridge suggests installing symfony/security (dev-master)
Writing lock file
Generating autoload files

As you can see, the first time I've runned the command it installed the twig-bridge, the second time it uninstalled it, the third time it installed it again; or the first time it removed symfony (dev-master) - installed it again and updated it until d1be45 then on the second time it installed a previous commit of symfony and updated it again to d1be45 and then the third time it did the same thing as the first time; You can also see that it is doing something strange with symfony/http-foundation and symfony/routing following the same pattern.

I haven't touched the composer.json file in between the update commands, so either I'm completely missing something (what wouldn't be the first time) or there is something wrong happening here.

Any help would be appreciated.

stof commented 12 years ago

I don't even see why the symfony/symfony package would be installed. It does not make any sense with your composer.json as you are only depending on some components, which should be used directly.

Did you reference symfony/symfony at some point in your composer.json, which could have messed confused composer later because of replacements ?

stof commented 12 years ago

On a side note, you should change your requirement for monolog as you forbid composer to use the latest stable version (1.2.0) whereas silex is totally compatible with it (There is no BC break in it)

marcos-abreu commented 12 years ago

The following are the steps I've done to my project:

First I've created a new folder and included the following composer.json file:

{
    "require": {
        "silex/silex": "1.0.*"
    },
    "minimum-stability": "dev"
}

Then I've typed:

curl -s http://getcomposer.org/installer | php

Then did composer.phar install - with the following output:

Loading composer repositories with package information
Installing dependencies
- Installing pimple/pimple (dev-master db836b)
  Cloning db836b8cfadc0f39dacafa2bf311a1ab603600bb

- Installing symfony/routing (dev-master d16a85)
  Cloning d16a85b229a7a01790998ad6bf66142860c3de5b

- Installing symfony/http-foundation (dev-master e706e8)
  Cloning e706e8673fc139de5d1ee4d2f2b8998d23e852b5

- Installing symfony/event-dispatcher (dev-master 421520)
  Cloning 421520fd35ace52106947b2d6c2d9db49cb5a866

- Installing symfony/http-kernel (dev-master c9df1d)
  Cloning c9df1d9f4a954d86a169f5744828aea72f16954b

- Installing silex/silex (dev-master 331454)
  Cloning 331454f7235da0aea8bd9c7e5fe5cfd9f043a069

symfony/routing suggests installing symfony/config (dev-master)
symfony/routing suggests installing symfony/yaml (dev-master)
symfony/routing suggests installing doctrine/common (>=2.2,<2.4-dev)
symfony/event-dispatcher suggests installing symfony/dependency-injection (dev-master)
symfony/http-kernel suggests installing symfony/browser-kit (dev-master)
symfony/http-kernel suggests installing symfony/class-loader (dev-master)
symfony/http-kernel suggests installing symfony/config (dev-master)
symfony/http-kernel suggests installing symfony/console (dev-master)
symfony/http-kernel suggests installing symfony/dependency-injection (dev-master)
symfony/http-kernel suggests installing symfony/finder (dev-master)
silex/silex suggests installing symfony/browser-kit (2.1.*)
silex/silex suggests installing symfony/css-selector (2.1.*)
silex/silex suggests installing symfony/dom-crawler (2.1.*)
Writing lock file
Generating autoload files

After done that without touching or creating any file, I've updated the composer.json to include monolog by updating the composer.json to:

{
    "require": {
        "silex/silex": "1.0.*",
        "symfony/monolog-bridge": "2.1.*",
        "monolog/monolog": ">=1.0.0,<1.2-dev"
    },
    "minimum-stability": "dev"
}

And then running composer.phar update - with the following output:

    Loading composer repositories with package information
Updating dependencies
  - Installing monolog/monolog (1.1.0)
    Downloading: 100%         

  - Installing symfony/monolog-bridge (dev-master 193de3)
    Cloning 193de3107a483251bf5728aca205c725681829a8

  - Updating symfony/symfony dev-master (d16a85 => d1be45)
    Checking out d1be451996e714afe65acd5d1ac946f10e96d46d

  - Updating symfony/symfony dev-master (e706e8 => d1be45)
    Checking out d1be451996e714afe65acd5d1ac946f10e96d46d

monolog/monolog suggests installing mlehner/gelf-php (Allow sending log messages to a GrayLog2 server)
Writing lock file
Generating autoload files

After done that without touching or creating any file, I've updated the composer.json to include twig by updating the composer.json to:

{
    "require": {
        "silex/silex": "1.0.*",
        "symfony/monolog-bridge": "2.1.*",
        "symfony/twig-bridge": "2.1.*",
        "monolog/monolog": ">=1.0.0,<1.2-dev",
        "twig/twig": ">=1.2.0,<2.0-dev"
    },
    "minimum-stability": "dev"
}

And then running composer.phar update - but I got a timeout before the update was complete, that was why I decided to run the update command again, and was when I started seeing the pattern I've described earlier - so I have not changed any file on the project manually other than the composer.json itself.

About the symfony/symfony I think it was installed because it is a dependency of silex - actually I think it as dependency of monolog, since it first appeared when I tried to include monolog as you can see on the output of the first update command.

About the the version I've used for monolog, I just followed the composer.json sample that comes when you download silex as fat version (http://silex.sensiolabs.org/download) - but thanks for the advice.

marcos-abreu commented 12 years ago

Also I would like to mention that I've been able to reproduce the same behaviour 4 times under to different networks (twice at my work and twice at home), and I got the time out after including the two lines for twig in 3 out of the 4 times. but in all 4 I've got the same strange pattern I've described.

So you may be able to reproduce the behaviour I've described if you follow the same steps I've described in the previous comment, and then after running update for the newly included twig lines, run it again and again to see if you can reproduce the bug.

Seldaek commented 12 years ago

Just to be sure, did you run self-update or download the latest composer version?

marcos-abreu commented 12 years ago

I haven't used the self-update command, actually I didn't know about it until you wrote your comment, and then I googled it.

I've installed composer by running the following command after I wrote my first version of composer.json:

curl -s http://getcomposer.org/installer | php
stof commented 12 years ago

@marcos-abreu the list of all available commands is documented: http://getcomposer.org/doc/03-cli.md (actually, the doc misses one: list which shows the list of available commands)

Seldaek commented 12 years ago

But could you confirm that this still happens with the latest version (after running composer self-update)?

marcos-abreu commented 12 years ago

I'll try to run self-update and I will post back soon.

marcos-abreu commented 12 years ago

I've done two tests - both of them I've started from an empty folder as a new project:

TEST 1:

TEST 2:

marcos-abreu commented 12 years ago

I just want to ask: can anyone replicate this strange behaviour following the steps I've described on my second comment?

marcos-abreu commented 12 years ago

Another thing that I want to say is that this seems to be related to the: "minimum-stability": "dev", because when I remove and my composer is:

{
    "require": {
        "silex/silex": "1.0.*",
        "symfony/monolog-bridge": "2.1.*",
        "symfony/twig-bridge": "2.1.*",
        "monolog/monolog": ">=1.0.0,<1.2-dev",
        "twig/twig": ">=1.2.0,<2.0-dev"
    }
}

The strange behaviour I've described earlier doesn't happen anymore.

marcos-abreu commented 12 years ago

Actually I should have said that it works if I follow the steps until, I get to the strange behaviour and then remove the "minimum-stability": "dev" - because if I start following the process of trying first to install just silex without the "minimum-stability": "dev" it won't install (this is documented here: https://github.com/fabpot/Silex/issues/417)

matteosister commented 12 years ago

I've just stumbled on a similar problem. It could be easily reproduced.

Here is my composer file:


{
    "name": "cypresslab/my-package",
    "require": {
        "symfony/console": "dev-master"
    },
    "minimum-stability": "dev"
}

composer is at last version, and I don't have any composer.lock or vendor directory. Here is the output:

$ composer install
Loading composer repositories with package information
Installing dependencies
  - Installing symfony/console (dev-master 4d463e)
    Cloning 4d463e30faf03f793c7b7184d7482ccdf71e1a05

all is well...now if I update look what happens:

$ composer update
Loading composer repositories with package information
Updating dependencies
  - Updating symfony/symfony dev-master (4d463e => 2c0e85)
    Checking out 2c0e851059905307e5a28ebe0b5153e8676585d1

Writing lock file
Generating autoload files

it installs symfony which is not referenced in the file, and obviously is not a dep of the console component.

another really weird thing is that symfony gets installed in the directory of the console component in

vendor/symfony/console/Symfony/Component/Console/src/Symfony/[Bridge,Bundle,Component]

Hope this help finding the problem!

Seldaek commented 12 years ago

Alright I figured out what it was, run composer self-update to get the fixed build.

matteosister commented 12 years ago

Thanks! For me the issue is gone :beer:

marcos-abreu commented 12 years ago

Thanks! I've just did a couple of tests and I can confirm that this fixed it for me!