openupm cli add package ignores unity min version
alelievr opened this issue · 4 comments
Hello,
I had an issue reported with one of my packages saying that the installation broke a unity project, and after investigating a bit I found out that openupm cli doesn't check if the package is compatible with unity before installing it, causing the project to break.
For example, I have my Mixture package which has a min unity version set to 2020.2 in the package.json: https://github.com/alelievr/Mixture/blob/master/Packages/com.alelievr.mixture/package.json#L5
And if I type the command to install this package openupm add com.alelievr.mixture
in a project with unity 2020.1, the package is added to the project and causes a compilation error. I think the cli should check if the package is compatible with the unity version before installing it.
And we have the same problem for dependencies, for example:
I have a package B that depends on version 2 of package A.
Package A is installed in the project using version 1, so adding the package B is not possible without upgrading A in the project before.
But openupm cli ignores this case too causing the project to break again.
I think openupm cli should check for both the package version and installed dependencies versions compatibility, it should be possible to use the major version to determine whether or not the package is compatible with another one.
Thanks for reporting the issue.
I agree that openupm-cli could verify the min unity version for the current package and its dependencies. It is possible by checking ProjectSettings/ProjectVersion.txt
.
And we have the same problem for dependencies, for example:
I have a package B that depends on version 2 of package A.
Package A is installed in the project using version 1, so adding the package B is not possible without upgrading A in the project before.
But openupm cli ignores this case too causing the project to break again.
The current Unity behavior is that if you already installed packageA@v1, then you installed package B that requires packageA@v2. Unity will install packageA@v2 for you, even you have specified packageA@v1 in manifest.json. Then I guess openupm-cli won't need to change anything. But if you have a different outcome with your test, I would like to revisit. (I had tested a few packages and verified the behavior before)
Close by version 1.13.0
- command add fails if the editor version is not qualified, unless passing option
-f
. - command add fails if a dependency is missing, unless passing option
-f
. - command add fails if a dependency's version is not found, unless passing option
-f
or manually installed a replaceable version. - command add will succeed and prompt nothing if a dependency requires a higher version, but a lower version is installed manually. Unity packman already handles this and will install the higher dependency version.
@all-contributors please add @alelievr for bug.
I've put up a pull request to add @alelievr! 🎉