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

[bug] Exact version range [==...] not working anymore with conan2 #16066

Closed
araffin opened this issue Apr 11, 2024 · 7 comments · Fixed by #16069
Closed

[bug] Exact version range [==...] not working anymore with conan2 #16066

araffin opened this issue Apr 11, 2024 · 7 comments · Fixed by #16069
Assignees

Comments

@araffin
Copy link
Contributor

araffin commented Apr 11, 2024

Describe the bug

Hello,
I'm currently in the process of upgrading recipes from conan1 to conan 2 and I found out that package/[==1.0.0] is no longer working with conan2 (but I couldn't find anything about that in the doc) and conan doesn't throw an error like for [~=1.0] which is now explicitly invalid.

ERROR: Package 'package_name/[==1.0.0]@pypi/stable' not resolved: Version range '==1.0.0' from requirement 'package_name/[==1.0.0]@pypi/stable' required by ... could not be resolved.

It would be nice to either throw a proper error message ("this version range is no longer supported, please upgrade to ..." and update the doc) or fix the bug and re-add support for it.

How to reproduce it

conan install --requires "any_pkg/[==1.0.0]@user/channel" vs conan install --requires "any_pkg/1.0.0@user/channel"

@memsharded memsharded self-assigned this Apr 11, 2024
@memsharded
Copy link
Member

Hi @araffin

Thanks for pointing this out.

The truth is that Conan 1 never intended to support [==version] syntax, for example the docs in https://docs.conan.io/1/versioning/version_ranges.html doesn't describe this syntax. Furthermore the https://github.com/podhmo/python-node-semver doesn't explicitly mention it either (it is true that docs are almost non-existing)

So it seems the python-node-semver implemented it and it "slipped" as a feature in Conan 1 we were not very aware, because the recommended approach for pinned dependencies in Conan both 1 and 2 is pkg/version without the [version] brackets.

As we implemented our own version ranges in Conan 2, the == was not managed at all, and this is what you are seeing.

I'll check if possible to throw a better error, or at least document it.

@valgur
Copy link
Contributor

valgur commented Apr 11, 2024

@araffin Is there any reason to use package/[==1.0.0] instead of plain package/1.0.0? It also has the potential unintended side effect of ignoring pre-release versions (e.g. 1.0.0-rc1).

@memsharded
Copy link
Member

I was thinking of allowing the == syntax in Conan 2, but I cannot find any reference online about this syntax, I have checked some resources like the closest to an official thing (https://docs.npmjs.com/cli/v6/using-npm/semver) to other languages docs, but no success.

@araffin
Copy link
Contributor Author

araffin commented Apr 11, 2024

Thanks for the swift answer, I guess a better error message would be helpful then.

Is there any reason to use package/[==1.0.0] instead of plain package/1.0.0?

To give a bit more context, I wrote a script to automatically convert python packages (from PyPi) to conan ones, and this was the most natural way to do the translation (for pinned version. For other version ranges, it is more hacky because pip and conan don't agree).

Side note: [1.0.0] do work with conan2.

@Da-LiFe
Copy link

Da-LiFe commented Apr 11, 2024

conan doesn't throw an error like for [~=1.0] which is now explicitly invalid.

I would argue, that the error message for [~=1.0] could also be improved in conan2:

Cannot bump '=2- version index 0, not an int is an explicit error, but not explicitly pointing towards the actual issue.

So if introducing a message for [==1.0] maybe you would also like to consider a new message for [~=1.0] as well.

@memsharded
Copy link
Member

To give a bit more context, I wrote a script to automatically convert python packages (from PyPi) to conan ones, and this was the most natural way to do the translation (for pinned version. For other version ranges, it is more hacky because pip and conan don't agree).

That explains it. The way we understood the Python/pip requirements is that pkg==version means a pinned dependency, i.e., that is not a version range, but a fixed dependency, while other expressions like >= define a version range. For context, we also treat it differently in Conan because initially Conan didn't have version ranges, it only implemented fixed/pinned dependencies. It was later that the version ranges were introduced with the [] syntax to avoid potential breakage, and we distinguish between pinned deps without brackets and version ranges with brackets. It is true that some equality expressions are admitted in version ranges, this is because of the [>=1 <2 || 3.1] syntax, very uncommon and not recommended for most cases, but supported.

I am submitting a PR to raise a better error message.

@memsharded
Copy link
Member

#16069 merged, it will cover both above cases, it will be in next Conan 2.3, thanks!

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

Successfully merging a pull request may close this issue.

4 participants