conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
7.97k stars 952 forks source link

fix back migration of default compatibility.py #16405

Closed memsharded closed 1 month ago

memsharded commented 1 month ago

Changelog: Fix: Implement a back migration to <2.3 for default compatibility.py plugin. Docs: Omit

craigscott-crascit commented 1 month ago

I don't think this is working as expected. We started seeing the error below in cases where we do some things with Conan 2.4.0, then switch to 2.2.1 and do some more things (the error is from the part after downgrading the conan cache from 2.4.0 to 2.2.1):

  ======== Computing necessary packages ========
ERROR: Unable to load conanfile in /<redacted>/.conan2/extensions/plugins/compatibility/compatibility.py
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/<redacted>/.conan2/extensions/plugins/compatibility/compatibility.py", line 3, in <module>
    from cppstd_compat import cppstd_compat
  File "/<redacted>/.conan2/extensions/plugins/compatibility/cppstd_compat.py", line 3, in <module>
    from conan.tools.build import supported_cppstd, supported_cstd
ImportError: cannot import name 'supported_cstd' from 'conan.tools.build' (/<redacted>/lib/python3.10/site-packages/conan/tools/build/__init__.py)
memsharded commented 1 month ago

That is indeed unexpected, thanks for reporting.

Could you please try to reproduce and share the traces after the downgrade? Conan should show information about the back-migration.

Any detail about and do some more things? Maybe there is another concurrent installation using the same cache?

We have tested down to Conan 2.0.17 and it seemed to work, I don't think the specific 2.2.1 version should be related.

craigscott-crascit commented 4 weeks ago

Could you please try to reproduce and share the traces after the downgrade? Conan should show information about the back-migration.

Any detail about and do some more things? Maybe there is another concurrent installation using the same cache?

I'm unlikely to be able to share traces due to confidentiality reasons, and no access to the CI system where these were seen. The project involved also had to put in a hot fix to block updating to 2.4.0, so I can't re-run it either.

The scenario was a CI job that used tox to create controlled environments and switch between them. I don't recall the exact order of things, but the last two steps were running in a tox environment with conan 2.4.0, then the last step in a tox environment with conan 2.2.1. It's possible that one or both used custom locations for the local conan cache. I think the conan commands were just the usual conan install ... type of thing. Sorry I can't be more specific, but it looks like @czoido may have found the underlying problem anyway, judging by #16417.

memsharded commented 4 weeks ago

Thanks for the feedback @craigscott-crascit

Yes, we have identified the possible issue: The back-migrations were designed as activated when there was a forward migration first, but not unconditionally. So mostly installing a fresh 2.4 in a new machine and downgrading it to 2.3 later was not possible, it was only enabled for users that first upgraded from 2.3 or lower to 2.4, and then decided to downgrade.

The PR https://github.com/conan-io/conan/pull/16417 is doing that, activating the back migrations uncondtionally. It is planned for next patch release 2.4.1, most likely next Monday or Tuesday.

Thanks very much again for the report, and sorry for the inconvenience.