Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How would I only update one composer dependency?

I expected that

composer update videlalvaro/php-amqplib 

would only update one dependency, but instead of that it updates all.

What am I missing?

PS: this dependency is defined as "videlalvaro/php-amqplib": "2.2.0" in composer.json

PPS: the composer version used is 3da05c68f9561fa822c522b1815435ff990493ff 2013-10-02 14:25:06

PPPS: the actual output:

$ composer.phar update videlalvaro/php-amqplib --no-dev Loading composer repositories with package information Updating dependencies Your requirements could not be resolved to an installable set of packages.    Problem 1     - symfony/icu v1.2.0 requires lib-icu >=4.4 -> the requested linked library icu has the wrong version installed or is missing from your system, make sure to have the extension providing it.     - symfony/icu v1.2.0 requires lib-icu >=4.4 -> the requested linked library icu has the wrong version installed or is missing from your system, make sure to have the extension providing it.     - Installation request for symfony/icu == 1.2.0.0 -> satisfiable by symfony/icu[v1.2.0]. 
like image 924
zerkms Avatar asked Oct 03 '13 00:10

zerkms


People also ask

How do you update a specific dependency in composer?

To update to the latest versions, use the update command. This will fetch the latest matching versions (according to your composer. json file) and update the lock file with the new versions.

How do I update a composer package to a specific version?

If you were hoping to switch to a specific version and check-in your composer. lock file, you can, but you'd have to use composer require and then revert the change to composer. json afterwards.


2 Answers

The command composer update videlalvaro/php-amqplib does just update that dependency. However it doesn't disable the other dependency checking that Composer does.

What the error message is complaining about is that the lib-icu is not available on your system. Apparently this would be solved by installing the PHP Intl extension.

You would see similar issues if you did a composer update on a project that required PHP 5.5 in one of it's requires, downgraded to PHP 5.4 and then ran composer update on a separate require, that didn't require PHP 5.5. Even though you wouldn't be updating the require that needs PHP 5.5, the requirements for that package would not be resolvable, and so Composer would fail.

In your case, even though you're just trying to update videlalvaro/php-amqplib to the latest version, the requirements for symfony/icu aren't met, and so the composer update fails.

Edit

To try to be helpful, I'm guessing you re-installed PHP since you last did an update, and either removed or forgot to install the PHP Intl extension. Composer can't satisfactorily satisfy the requirements your composer.json is setting, and so is defaulting to doing nothing, rather than knowingly doing an update where the requirements aren't met.

So basically, you need to install the PHP extensions that are required for your existing installed software to run, and then Composer will be able to update the single package you want to update, as well as meet the requirements for the other packages.

like image 197
Danack Avatar answered Oct 11 '22 04:10

Danack


tl;dr:

You can list more than one dependency to update in one command:

composer update one/dependency second/dependency other/dependency 

Story:

If you want to update only one dependency (composer update some/dependency), you may face an issue that request is not satisfiable due to some other dependency is installed in wrong version. And that one does not necessarily must be listed in your composer.json, it could be just dependency of some other dependency.

E.g. I wanted to update only and only google/apiclient, but calling composer update google/apiclient complained, that google/auth (dependency of apiclient) requires guzzlehttp/psr7 in version 1.2.3. I had 1.3.0 installed. The guzzlehttp/psr7 was not listed in my composer.json. What I had to do, was to call:

composer update guzzlehttp/psr7 google/apiclient 

and that's it! Just update the package you want, and if composer tells you, that you need to update (or downgrade :-)) some other package, list it in the command.

like image 37
hejdav Avatar answered Oct 11 '22 06:10

hejdav