docs
docs copied to clipboard
Conan workflow does not work with conan-center index
I am trying to run conan workflow with one of the recipes and it does not work for me. Question is why?
conan source . diligent-tools/2.5.2@andrei/test --source-folder=tmp/source &&
conan install . --install-folder=tmp/build -pr clang &&
conan build . --source-folder=tmp/source --build-folder=tmp/build &&
conan package . --source-folder=tmp/source --build-folder=tmp/build --package-folder=tmp/package
Traceback (most recent call last):
File "/home/andrei/.local/lib/python3.9/site-packages/conans/client/command.py", line 2238, in run
method(args[0][1:])
File "/home/andrei/.local/lib/python3.9/site-packages/conans/client/command.py", line 842, in source
raise ArgumentError(None,
argparse.ArgumentError: 'conan source' doesn't accept a reference anymore. If you were using it as a concurrency workaround, you can call 'conan install' simultaneously from several different processes, the concurrency is now natively supported. The path parameter should be a folder containing a conanfile.py file.
ERROR: 'conan source' doesn't accept a reference anymore. If you were using it as a concurrency workaround, you can call 'conan install' simultaneously from several different processes, the concurrency is now natively supported. The path parameter should be a folder containing a conanfile.py file.
conan source no longer takes a <reference> argument, that was removed like years ago.
The documentation doesn't show this anymore, do you see it somewhere?
The correct form is conan source . without any reference.
Furthermore, I would recommend trying the new layout(), that is, using the conan new hello/0.1 -m=cmake_lib template as a start, for example, and then you can avoid the --source-folder and --build-folder arguments
conan source . --source-folder=tmp/source
also does not work, as there is no version defined and it fails in source methid. Is there any correct way of using conan source with conan-center index? it should be documented
Oh, I see what you mean. It is true, it doesn't work out of the box.
The workaround is to add the version = "xxx" directly in the conanfile.py.
This has been solved already in 2.0, where the conan source got arguments like --version.
A discussion in Slack explained to me that the correct order should be:
conan install . diligent-tools/2.5.2@andrei/test --install-folder=tmp/build -pr clang &&
conan source . --install-folder=tmp/build --source-folder=tmp/source &&
- First you
conan installspecifying full reference and install folder - this will download dependencies and populatetmp/build/with files about versions, options, settings, etc. - Then you
conan sourcereusing the install folder and generated files in it.
FWIW, for conan source alone it seems that having only conan.lock and graph_info.json is enough. For my needs (testing solely that source() works and source tarballs are available), those two files could be generated manually:
def write_graph(name: str, version: str, install_folder: Path) -> None:
graph = {
"options": [],
"root": {
"name": name,
"version": version,
"user": "avail",
"channel": "script"
}
}
with open(install_folder / 'graph_info.json', 'w') as f:
json.dump(graph, f, indent=1)
def write_lock(name: str, version: str, install_folder: Path) -> None:
lock = {
"graph_lock": {
"nodes": {
"0": {
"ref": f'{name}/{version}@avail/script',
}
},
},
"profile_host": "[settings]\narch=x86_64\narch_build=x86_64\nbuild_type=Release\ncompiler=gcc\ncompiler.libcxx=libstdc++\ncompiler.version=11\nos=Linux\nos_build=Linux\n[options]\n[build_requires]\n[env]\n"
}
with open(install_folder / 'conan.lock', 'w') as f:
json.dump(lock, f, indent=1)
I would highly advise against meddling with internal files generated by Conan though, and just stick to conan install when possible :smiley: