I have a Composer package that requires OtherPackage vs 1.0.*. I know that version 1.0.3 exists, but it keeps downloading version 1.0.1. I can't figure out why it is not getting the latest version.
my composer.json file:
"require": {
"MyVendor/OtherPackage": "1.0.*",
}
I figured this out because I tried to force version 1.0.3 and got the following error:
Your requirements could not be resolved to an installable set of packages.
- Installation request for myVendor/OtherPackage 1.0.3 -> satisfiable by MyVendor/OtherPackage[1.0.3]
- MyVendor/OtherPackage 1.0.3 requires OtherVendor/ThirdPackage 1.0.1 -> no matching package found.
So that's when I remembered that MyVendor/OtherPackage 1.0.1 didn't have the ThirdPackage dependency, while 1.0.2 and 1.0.3 did. I didn't include ThirdPackage in my composer.json requirements. As a result Composer was smart enough to get the latest version of OtherPackage that was satisfiable for all of my current dependencies.
My solution was just to add OtherVendor/ThirdPackage 1.0.1 to my requires declaration in composer.json.
My new composer.json
"require": {
"MyVendor/OtherPackage": "1.0.*",
"OtherVendor/ThridPackage":"1.0.1"
},
Related
I tried updating brianium/paratest from ^6.6 to the latest version of ^7.0 and now, when I try to run composer install, I get this message:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires vimeo/psalm ^4.29 -> satisfiable by vimeo/psalm[4.29.0, 4.30.0].
- brianium/paratest[v7.0.0, ..., v7.0.1] require phpunit/phpunit ^10.0.3 -> satisfiable by phpunit/phpunit[10.0.3, 10.0.4].
- phpunit/phpunit[10.0.3, ..., 10.0.4] require sebastian/diff ^5.0 -> satisfiable by sebastian/diff[5.0.0].
- Conclusion: don't install sebastian/diff 5.0.0 (conflict analysis result)
- Root composer.json requires brianium/paratest ^7.0 -> satisfiable by brianium/paratest[v7.0.0, v7.0.1].
Error: Your requirements could not be resolved to an installable set of packages.
Problem 1
- Root composer.json requires vimeo/psalm ^4.29 -> satisfiable by vimeo/psalm[4.29.0, 4.30.0].
- brianium/paratest[v7.0.0, ..., v7.0.1] require phpunit/phpunit ^10.0.3 -> satisfiable by phpunit/phpunit[10.0.3, 10.0.4].
- phpunit/phpunit[10.0.3, ..., 10.0.4] require sebastian/diff ^5.0 -> satisfiable by sebastian/diff[5.0.0].
- Conclusion: don't install sebastian/diff 5.0.0 (conflict analysis result)
- Root composer.json requires brianium/paratest ^7.0 -> satisfiable by brianium/paratest[v7.0.0, v7.0.1].
Error: Process completed with exit code 2.
Here's my composer.json:
"require": {
"php": ">=8.1"
},
"require-dev": {
"ext-xml": "*",
"brianium/paratest": "^7.0",
"friendsofphp/php-cs-fixer": "^3.12",
"php-parallel-lint/php-parallel-lint": "^1.3",
"squizlabs/php_codesniffer": "^3.7",
"vimeo/psalm": "^4.29"
},
I'm not requiring sebastian/diff myself so I can't remove it as a requirement. Per the output I guess phpunit/phpunit is but if it were the only thing requiring sebastian/diff then I don't see how there'd be a conflict. So it seems like something else must be requiring sebastian/diff, albeit a different version, but I have no idea what.
I suppose I could look at each my deps and consider upgrading each one of them, as well, but idk... that could be a huuuge PITA if I had a lot of deps. Is there no better way to figure out what's going on?
I did do that for my specific composer.json and it looks like PHP-CS-Fixer/PHP-CS-Fixer (even the latest version of v3.14.3) requires ^4.0 whereas phpunit/phpunit 10.x requires ^5.0 so I guess that's the issue but I feel like I shouldn't need to have to look at each individual repo's composer.json to figure that out.
Just have a look at the requirements of vimeo/psalm. v4 requires sebastian/diff in v3 or v4, as you can see on https://packagist.org/packages/vimeo/psalm#4.29.0, and this is obviously incompatible with PHPUnit v10, as this requires sebastian/diff in v5.
You could check if your application supports running Psalm v5. And if not, this is a great example for why you should not install tools like Psalm using Composer
Also, next time you run such an update, composer why-not could help. In your example, composer why-not brianium/paratest 7.0.1 could have pointed out the incompatible package
I tried in cmd "composer require nesbot/carbon" but I got this:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- laravel/framework v5.6.27 requires nesbot/carbon 1.25.* -> satisfiable by nesbot/carbon[1.25.0] but these conflict with your requirements or minimum-stability.
- laravel/framework v5.6.27 requires nesbot/carbon 1.25.* -> satisfiable by nesbot/carbon[1.25.0] but these conflict with your requirements or minimum-stability.
- laravel/framework v5.6.27 requires nesbot/carbon 1.25.* -> satisfiable by nesbot/carbon[1.25.0] but these conflict with your requirements or minimum-stability.
- Installation request for laravel/framework (locked at v5.6.27, required as 5.6.*) -> satisfiable by laravel/framework[v5.6.27].
Installation failed, reverting ./composer.json to its original content.
I don't recommend doing this without extreme caution because there may be a reason why Laravel, or any of your other dependencies, require a very strict version of a package.
With that said, Composer does include a neat trick to alias versions to get around this by specifying an alias version in composer.json:
"require": {
...
"nesbot/carbon": "1.32.0 as 1.25.0"
},
Note the as 1.25.0 which will trick other packages into thinking 1.32.0 is equivalent to 1.25.0 for dependencies. This trick requires exact versions.
Carbon 2 is officially supported by Laravel since the version 5.8, if you want to use it on a lower version, you can follow those steps:
Set explicitly the Carbon version and add the adapter in your composer.json:
{
"require": {
"nesbot/carbon": "2.21.3 as 1.34.0"
}
}
I have Symfony Demo Application up and running and now I'm trying to install API Platform as a standalone bundle.
I'm using PHP 7.0.10 with latest composer, but my previous test was using PHP 5.6.20.
When I try to add API Platform Core as a dependency, I get the following error message:
$ composer require api-platform/core
Using version ^1.1 for api-platform/core
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for symfony/symfony (locked at v3.2.8, required as ^3
.2) -> satisfiable by symfony/symfony[v3.2.8].
- api-platform/core v1.1.0 requires phpdocumentor/reflection ^1.0.7 -> satis
fiable by phpdocumentor/reflection[1.0.7].
- api-platform/core v1.1.1 requires phpdocumentor/reflection ^1.0.7 -> satis
fiable by phpdocumentor/reflection[1.0.7].
- Conclusion: don't install phpdocumentor/reflection 1.0.7
- Installation request for api-platform/core ^1.1 -> satisfiable by api-plat
form/core[v1.1.0, v1.1.1].
Installation failed, reverting ./composer.json to its original content.
In your composer.json file:
Find:
"symfony/symfony": "3.2.*",
Replace with:
"symfony/symfony": "3.3.*",
...or:
"symfony/symfony": "^3.2.*",
You'll probably need (want) to run composer update first, THEN add your api-platform package with composer require api-platform/core so you have all the dependencies properly loaded, but it's not essential.
With PHP 7.x, you should be using ^2.0, e.g.
composer require api-platform/core ^2.0
Note: To workaround PHP 7.x requirements, you can try to add --ignore-platform-reqs.
If you get the error about minimum-stability, change it to beta in your composer.json file.
Source: Compatibility issue when using composer require with symfony 3.1.4 at GitHub.
See: Installing API Platform Core.
I am working with multiple composer packages as a library and sometimes those packages require each other. For example, in modolib/phpunit I have:
"require": {
"modolib/doctrine": "~1.2",
}
and in the package modolib/doctrine I have:
"require-dev": {
// ...
"modolib/phpunit": "~1.3"
},
To version the packages, I use tags. Calling git tag for modolib/phpunit in branch master puts out:
// ...
1.2.8
1.2.9
1.2.10
1.3.0
1.3.1
// ...
1.3.10
and git tag for modolib/doctrine at branch master puts out:
// ...
1.2.8
1.2.9
1.2.10
1.2.11
1.2.12
However, a composer update in modolib/phpunit will perfectly work, but an update in modolib/doctrine will throw this error:
Problem 1
- modolib/phpunit 1.3.9 requires moodlib/doctrine ~1.2 -> no matching packages found
- modolib/phpunit 1.3.8 requires moodlib/doctrine ~1.2 -> no matching packages found
- modolib/phpunit 1.3.7 requires moodlib/doctrine ~1.2 -> no matching packages found
- modolib/phpunit 1.3.5 requires moodlib/doctrine 1.2.* -> no matching packages found
- modolib/phpunit 1.3.4 requires moodlib/doctrine 1.2.* -> no matching packages found
- modolib/phpunit 1.3.3 requires moodlib/doctrine 1.2.* -> no matching packages found
- modolib/phpunit 1.3.2 requires moodlib/doctrine 1.2.* -> no matching packages found
- modolib/phpunit 1.3.10 requires moodlib/doctrine 1.*.* -> no matching packages found
- modolib/phpunit 1.3.1 requires moodlib/doctrine 1.2.* -> no matching packages found
- modolib/phpunit 1.3.0 requires moodlib/doctrine 1.2.* -> no matching packages found
- Installation request for modolib/phpunit ~1.3 -> satisfiable by modolib/phpunit[1.3.0, 1.3.1, 1.3.10, 1.3.2, 1.3.3, 1.3.4, 1.3.5, 1.3.7, 1.3.8, 1.3.9]
The current version of modolib/doctrine is 1.2.12 and no commits have been added since I created this tag except for the merge to master (I am using git flow).
Now it seems like the expression "modolib/doctrine": "~1.2" is correct, since I can update the packages in modolib/phpunit itself, but the composer has problems with noticing I am working in the package it is trying to request. Or could it have something to do with the difference between require and require-dev?
How can I solve this error and update my packages in modolib/doctrine?
UPDATE:
The reason why the update in modolib/phpunit worked is because modolib/doctrine requires modolib/phpunit in require-dev, but the composer does not load the require-dev sections of the packages it's loading during the update. Therefore, from the view of modolib/phpunit the packages do not require each other. Only modolib/doctrine is loaded, but it does not try to load modolib/phpunit while working in this repository.
The composer does notice if the requirement is the package you are currently working in. What it does not notice is the tagged version. Of course Composer can not read your repository tags, so you need to provide them in the composer.json:
"name": "modolib/doctrine",
"version": "1.2.12",
// ...
"require-dev": {
// ...
"modolib/phpunit": "~1.3"
},
Now composer knows both name and version of your package and can validate the dependency.
I am trying to install this package
ExeuAmazonECSBundle
"require": {
"php": ">=5.3.3",
.
.
.
"exeu/amazon-ecs-bundle": "dev-master"
},
then
sudo php composer.phar update exeu/amazon-ecs-bundle
However it indicates two error potential, I have confirmed it is not type.
my setting is
"minimum-stability": "alpha",
and I can install other bundle as 'dev-master'
How can I slove this?
Problem 1
- Installation request for exeu/amazon-ecs-bundle dev-master -> satisfiable by exeu/amazon-ecs-bundle[dev-master].
- exeu/amazon-ecs-bundle dev-master requires exeu/amazon-ecs-php dev-master -> no matching package found.
Problem 2
- exeu/amazon-ecs-bundle dev-master requires exeu/amazon-ecs-php dev-master -> no matching package found.
- symfony/framework-standard-edition 2.2.x-dev requires exeu/amazon-ecs-bundle dev-master -> satisfiable by exeu/amazon-ecs-bundle[dev-master].
- Installation request for symfony/framework-standard-edition 2.2.x-dev -> satisfiable by symfony/framework-standard-edition[2.2.x-dev].
Potential causes:
- A typo in the package name
- The package is not available in a stable-enough version according to your minimum-stability setting
see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.
Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.
The error message is quite clear about what the problem is.
You need to contact the guy wrote that library and ask him to also publish the library 'exeu/amazon-ecs-php' which apparently 'exeu/amazon-ecs-bundle' is dependent on.
The package amazon-ecs-php isn't available in any stability, which is why composer is failing.