Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

force a single dependency to install on different (lower) requirements #6126

Closed
photodude opened this issue Feb 3, 2017 · 12 comments
Closed

Comments

@photodude
Copy link

My composer.json:

{
	"name": "akeeba/fof",
	"type": "library",
	"description": "FOF (Framework on Framework) is a Rapid Application Development framework for Joomla!",
	"require" : {
		"php": ">=5.3.4",
		"nikic/php-parser": "^3.0"
	},
	"keywords": ["framework","joomla","mvc","rad"],
	"homepage": "https://github.com/akeeba/fof",
	"license": "GPL-2.0+",
	"authors": [
		{
			"name": "Nicholas K. Dionysopoulos",
			"email": "nicholas_NO_SPAM_PLEASE@akeebabackup.com",
			"homepage": "http://www.dionysopoulos.me",
			"role": "Lead Developer"
		}
	],
	"require-dev": {
		"mikey179/vfsStream": "dev-master",
		"phpunit/phpunit": "~4.5.0",
		"phpunit/dbunit": "~1.2",
		"mockery/mockery": "0.9.4",
		"fiunchinho/phpunit-randomizer": "1.0.*@dev"
	},
	"autoload" : {
		"psr-4": {
			"FOF30\\": "fof"
		}
	}
}

on php 5.3 and 5.4 I get the following output:

  Problem 1
    - Installation request for nikic/php-parser v3.0.2 -> satisfiable by nikic/php-parser[v3.0.2].
    - nikic/php-parser v3.0.2 requires php >=5.5 -> your PHP version (5.3.29) does not satisfy that requirement.

And I expected this to be possible:

on php 5.3 and php 5.4 I want to override just the one package nikic/php-parser requires php >=5.5 to force install version 3

current capabilities of as won't allow broad version aliasing since
Could not parse version constraint ~3.0 as 1.0: Invalid version string "~3.0" in "~3.0 as 1.0", the alias source must be an exact version

current capabilities of config platform doesn't seem to have options to specify just a single dependency to fake platform packages (PHP and extensions) so that you can emulate a production env on just a single dependency. additionally it also does not seem to be able to specify multiple platform options to fake PHP as in fake 5.5 for <= 5.4 and exact for >=5.5

alternative options was the following json

{
	"name": "akeeba/fof",
	"type": "library",
	"description": "FOF (Framework on Framework) is a Rapid Application Development framework for Joomla!",
	"require": {
		"php": "~5.3.10||~5.4.10||>=5.5",
		"nikic/php-parser": "~1.0||~2.0||~3.0"
	},
	"keywords": ["framework","joomla","mvc","rad"],
	"homepage": "https://github.com/akeeba/fof",
	"license": "GPL-2.0+",
	"authors": [
		{
			"name": "Nicholas K. Dionysopoulos",
			"email": "nicholas_NO_SPAM_PLEASE@akeebabackup.com",
			"homepage": "http://www.dionysopoulos.me",
			"role": "Lead Developer"
		}
	],
	"require-dev": {
		"mikey179/vfsStream": "dev-master",
		"phpunit/phpunit": "~4.8",
		"phpunit/dbunit": "~1.4",
		"mockery/mockery": "0.9.4",
		"fiunchinho/phpunit-randomizer": "1.0.*@dev"
	},
	"autoload" : {
		"psr-4": {
			"FOF30\\": "fof"
		}
	}
}

This is not an elegant solution and I would rather just force the dependency to install 3.0 on both php 5.3 and php 5.4

@alcohol
Copy link
Member

alcohol commented Feb 3, 2017

Alias should be to a specific version, not to a version constraint. You have to pick a specific version that satisfies the constraint that the other library requires.

@alcohol
Copy link
Member

alcohol commented Feb 3, 2017

If you however don't want to alias an older version as 3.x, but rather want to actually install 3.x on a php 5.3 or php 5.4 system (which seems really dumb, since it explicitly does not support that), then you could just call composer install --ignore-platform-reqs.

@alcohol alcohol closed this as completed Feb 3, 2017
@photodude
Copy link
Author

@alcohol, your comments do not solve the issues. Please read my full comments, I specifically mentioned 3 ways I tried to address the issue of only forcing one dependency to ignore the requirements of just a specific package. Alias was only one item.

Using the command line argument is not a solution that I want as it is far to broad. Additionally it's not a valid solution for others using the package.

@stof
Copy link
Contributor

stof commented Feb 3, 2017

Well, if nikic/php-parser tells you that the 3.0 version does not work on PHP 5.4, why would you want to force installing it ? even if you force composer to bypass the platform check, it would not work.

@photodude
Copy link
Author

photodude commented Feb 3, 2017

@stof nikic/php-parser tells us they only support php 5.5+ but they also note that there is nothing that would prevent it from working with php 5.3.

That aside, we use nikic/php-parser in the framework as part of a CLI tool for developing on the framework with the note that it should be used only in php 5.6. So between nikic/php-parser actually working on php 5.3 and this is a CLI tool that only developers are going to use, installing on php <=5.5 is not a concern for us. The problem is, nikic/php-parser needs to be required in the framework package (and not just in dev mode) and thus breaks the CI testing on travis and when others composer install the framework on PHP <=5.5

@alcohol
Copy link
Member

alcohol commented Feb 6, 2017

I gave you a solution. That you did not accept it (for whatever reasons), is not my problem. There is no issue here, other than you being stubborn.

@stof
Copy link
Contributor

stof commented Feb 6, 2017

but they also note that there is nothing that would prevent it from working with php 5.3.

that's wrong. The nikic/php-parser codebase can parse PHP 5.3 code. but it cannot run on PHP 5.3 (I'm not sure whether it can run on PHP 5.4, but I'm 100% sure it cannot run on 5.3 as the first file I checked is using the short array syntax)

@photodude
Copy link
Author

photodude commented Feb 6, 2017

@alcohol I gave a "solution" using || between the versions in full json for my issue statement. I apparently have failed to explain the issue and use intent properly so that you actually understand it. The "solution" you provided does not improve on the || version solution in the full json I provided. I take your "solution" as an option but not as a solution to the use case I'm describing. Again, I clearly have not explained it well enough to be understood (or no one is actually reading what I've written).

using composer install --ignore-platform-reqs will ignore platform requirements for all packages not just the single package we care to ignore, it's also not a portable solution for consuming packages. It's an option but not the kind of solution we are looking for. If we could specify a package as composer install --ignore-platform-reqs "nikic/php-parser" that would meet the first part we need but still would not be portable for consuming packages.

@photodude
Copy link
Author

photodude commented Feb 6, 2017

@stof Maybe I misunderstood a statement I read in the nikic/php-parser version history about what versions it will work on vs what php versions they support.

but like I said, we don't actually care if nikic/php-parser 3.x works on lower php versions as it's only included in the package as a CLI tool for developers to use in >php5.3

unfortunately, we now have issues with composer installs for <php 5.5 in our CI testing environments. Hence the use case for force a single dependency to install on different (lower) requirements

@photodude
Copy link
Author

Additionally, if I take the full json with the || between versions and create a lock file we do not get a lock file that works for all of the different versions. We actually break everything for php 5.5 with the lock file.
see this travis build https://travis-ci.org/akeeba/fof/builds/198759376

@ghost
Copy link

ghost commented Jul 4, 2018

The inability to include a package without checking for its requirements is still a major issue.

Common use case is to update a framework but a module has not updated its composer.json requirements to be compatible with the new version.

@alcohol
Copy link
Member

alcohol commented Jul 5, 2018

@jonaseberledmind putting the burden of solving that on the package manager instead of the library maintainer is just approaching the problem the wrong way around in my opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants