Search code examples
c++gitlabimporterrorconan

Conan import error in gitlab pipeline - Cannot load recipe


Here is the error getting during build-job in gitlab pipeline. This was initially working for days in the pipeline build and without any update in the code repository, import error started to happen. It would be nice if anyone can shed some light on it.

Conan version in the pipeline runner image is Conan version 1.51.3

gtest/1.10.0: Not found in local cache, looking in remotes...
gtest/1.10.0: Trying with 'conancenter'...
Downloading conanmanifest.txt
Downloading conanfile.py
Downloading conan_export.tgz
gtest/1.10.0: Downloaded recipe revision 0
ERROR: gtest/1.10.0: Cannot load recipe.
Error loading conanfile at '/root/.conan/data/gtest/1.10.0/_/_/export/conanfile.py': Unable to load conanfile in /root/.conan/data/gtest/1.10.0/_/_/export/conanfile.py
  File "/usr/lib/python3.10/imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 719, in _load
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/root/.conan/data/gtest/1.10.0/_/_/export/conanfile.py", line 6, in <module>
    from conan.tools.files import apply_conandata_patches, export_conandata_patches, copy, get, replace_in_file, rm, rmdir
ImportError: cannot import name 'export_conandata_patches' from 'conan.tools.files' (/usr/local/lib/python3.10/dist-packages/conan/tools/files/__init__.py)

Looking forward to hearing from you soon. Best, Honey

Honey Sukesan


Solution

  • The export_conandata_patches is available since Conan 1.52.0.

    You need to update your Conan client version:

    pip install -U conan
    

    Since Conan 1.52.0, required_conan_version is validated before parsing those imported modules, so it fail soon and validate your Conan client version first.