Composer won't install dependency [duplicate] - php

This question already has answers here:
but these conflict with your requirements or minimum-stability
(6 answers)
Closed 1 year ago.
I have created a composer package with this composer.json
{
"name": "webiny/cache",
"type": "library",
"minimum-stability": "dev",
"require": {
"php": ">=5.4.0",
"jamm/memory": "dev-master"
},
"require-dev": {
"phpunit/phpunit": "4.1.*"
},
"autoload": {
"psr-4": {
"Webiny\\Component\\Cache\\": ""
}
},
"extras": {
"branches": {
"dev-master": "~0.9"
}
}
}
I'm having a problem with resolving jamm/memory package when I do a composer install on this file:
{
"require": {
"webiny/cache": "dev-master"
}
}
The error I get is
Problem 1
- Installation request for webiny/cache dev-master -> satisfiable by webiny/cache[dev-master].
- webiny/cache dev-master requires jamm/memory dev-master -> no matching package found.
When I just try to install the jamm/memory if works fine:
{
"require": {
"jamm/memory": "dev-master"
}
}
I have the minimum-stability flag set to dev in webiny\cache. I have also tried setting the release to #dev on jamm/memory dependency...didn't help.
I can't figure out what I'm doing wrong.

Solved it....
I added the minimum-stability flag to the composer.json file that I used to install the libraries...not just on the composer.json file that is used to define a package.

Related

Asana Installation using composer

I am trying to install the asana library through the composer.
Json:
"asana/asana": "^0.10.0" added to composer.json and {
"name": "asana/asana",
"description": "A PHP client for the Asana API",
"type": "library",
"keywords": ["asana", "client"],
"homepage": "https://github.com/Asana/php-asana",
"license": "MIT",
"require": {
"php": ">=5.4.0",
"nategood/httpful": "~0.2",
"adoy/oauth2": "^1.2.0"
},
"require-dev": {
"instaclick/php-code-sniffer": "dev-master",
"phpunit/phpunit": "^9"
},
"autoload": {
"psr-0": {
"Asana\\": "src/"
}
}
}
to composer.lock but getting error 'Package Asana/asana has no version defined.
'
As suggested by #Jeto you should not edit composer.lock manually. To install the library, you can follow the steps mentioned in official docs here.
Assuming that you are doing a fresh install, follow steps below:
Put "asana/asana" package as a dependency in your composer.json file:
{
"require": {
"asana/asana": "^0.10.0"
}
}
Now run the command composer install
composer.lock file will be automatically updated by Composer when installation succeed.
EDIT:
OR
As mentioned by #Jeto in comments, You can simply do this using a single command: composer require asana/asana:^0.10.0

Library requires "dev-master" and a stable version

I am developing an add-on (atk4/audit) for a framework (atk4/data). My basic composer.json looks like this:
{
"type": "library",
"name": "atk4/audit",
"require": {
"atk4/data": "^1.3",
"php": ">=5.6.0"
}
}
This works fine and if composer require atk4/audit is used, then atk4/audit[1.0] and atk4/data[1.3] is installed.
However when attempted to use development branches:
{
"require": {
"atk4/data": "dev-develop",
"myaddon/addon": "dev-develop"
}
}
composer responds with error:
Problem 1
- Installation request for atk4/data dev-develop -> satisfiable by atk4/data[dev-develop].
- atk4/data dev-develop requires atk4/dsql dev-develop -> satisfiable by atk4/dsql[dev-develop] but these conflict with your requirements or minimum-stability.
Problem 2
- Installation request for atk4/audit dev-develop -> satisfiable by atk4/audit[dev-develop].
- atk4/audit dev-develop requires atk4/schema dev-develop -> satisfiable by atk4/schema[dev-develop] but these conflict with your requirements or minimum-stability.
I want my library to be usable in both "stable" and "dev-develop" versions. I have tried setting composer.json like this for the library:
{
"type": "library",
"name": "atk4/audit",
"require": {
"atk4/data": "dev-develop,^1.3",
"php": ">=5.6.0"
}
}
but, this does not work. I haven't found any mentions of this issue anywhere, I wonder if I'm on the wrong path?
When defining an unstable dependency with Composer, you need to specify the minimum stability.
{
"require": {
"atk4/data": "dev-develop",
"myaddon/addon": "dev-develop"
},
"minimum-stability": "dev"
}
You should also add "prefer-stable": true, otherwise all non-versionned packages in composer.json will be updated to the unstable branch.

Composer error: no matching package found

I have two Symfony projects: project-a (root project) and project-b.
My composer.json file from project-a contains:
{
"name": "myprojects/project-a",
"require": {
"myprojects/project-b": "dev-master",
},
"repositories": [
{
"type": "vcs",
"url": "git#bitbucket.org:MYPROJECTS/project-b.git"
}
]
}
And my composer.json from project-b:
{
"name": "myprojects/project-b",
"require": {
"guzzlehttp/guzzle": "^6.3"
}
}
I need to update project-b but when I execute the command composer update myprojects/project-b from project-a, I get this composer error:
[Composer\DependencyResolver\SolverProblemsException]
Problem 1
Installation request for myprojects/project-b dev-master -> satisfiable by
myprojects/project-b[dev-master].
myprojects/project-b dev-master requires guzzlehttp/guzzle ^6.3 -> no matching package found.
Potential causes:
A typo in the package name
The package is not available in a stable-enough version according to your minimum-stability setting
I have tried solve this adding "minimum-stability": "dev" property to both composer.json files, but it doesn't works.. How can I solve this?
Thanks.
As commented in guzzle/guzzle issue 861:
Looks like an issue with your caching.
Try clearing your composer cache, and self-update composer, then try again.
The OP Wildchild confirms in the comments:
composer clear cache and self-update solves my problem
"minimum-stability": "dev" is not needed.

error when trying to run composer install - "requirements could not be resolved"

I started working with PHPUnit a few days ago and came across this issue.
I want to test some classes in a project i cloned from github.
in the project there are two folders: "tests" and "src" and in each one of them composer.json file.
in the src folder the file looks like this:
{
"require": {
"php": ">=5.3.0",
"monolog/monolog": "1.*",
"slim/slim": "2.*"
},
"autoload": {
"classmap": ["classes/"]
}
}
and in the tests folder the file looks like this:
{
"require-dev": {
"phpunit/phpunit": "dev-master"
},
"autoload": {
"psr-0": {
"adServerTesting": ""
}
}
}
so i created this one united composer.json :
{
"require": {
"php": ">=5.3.0",
"monolog/monolog": "1.*",
"slim/slim": "2.*"
},
"require-dev": {
"phpunit/phpunit": "dev-master"
},
"autoload": {
"classmap": ["classes/"],
"psr-0": {
"adServerTesting": ""
}
}
}
but when i run composer install i get the following error:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for phpunit/phpunit dev-master -> satisfiable by phpunit/phpunit[dev-master].
- phpunit/phpunit dev-master requires php >=5.6 -> your PHP version (5.5.9-1ubuntu4.11) does not satisfy that requirement.
since i have phpunit installed on my machine i tried to run the composer install from inside the src folder path and great, command and tests executed properly but now after uniting the files i get this error. I see it says i have php 5.5.9 which i need to upgrade but than why did it work when i run the composer install from the src folder?? thx..
phpunit/phpunit:#dev reuqires PHP 5.6 and your PHP version is 5.5.
Use lower version of PHPUnit, or rather let composer decide that. You can do that by calling:
composer require phpunit/phpunit --dev
--dev option for adding to require-dev section.

Composer dependency issue with external repository

I have written a library that I want to use in another project. However, when I add the library dependency to my project I get the following error after running composer update -vvv:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- Installation request for my/library dev-master -> satisfiable by my/library[dev-master].
- my/library dev-master requires doctrine/migrations dev-master -> no matching package found.
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.
This error is very confusing to me since my project has my library as it's only dependency, i.e. my project composer.json looks like this:
{
"name": "my/project",
"type": "project",
"description": "My project",
"autoload": {
"psr-0": { "MyNamespace\\": ["src/", "tests/src/"] }
},
"repositories": [ {
"type": "vcs",
"url": "git#bitbucket.org:my/library"
} ],
"require": {
"php": ">=5.5",
"my/library": "dev-master"
},
"require-dev": {
"phpunit/phpunit": "3.*"
}
}
As you can see, pretty straight forward. The reason the version of my library is requiring dev-master is because master is currently the only branch I work on (I work alone, no need for other branches at the moment).
So far the only way for the resolve this problem is by adding the dependencies of my library composer.json to my project's composer.json which seems like an unnecessary step.
How can I resolve this dependency issue?
It looks to me as if it is a stability issue. Add the following two lines to your composer.json:-
"minimum-stability": "dev",
"prefer-stable": true,
ref:- minimum-stability & prefer-stable
Hopefully that will sort out your problem.

Categories