Search code examples
conan

Cannot specify name and version when generating a lock file


I am using a simple conan file example from a repository of examples. I would like to generate a lockfile, but when I try the command, I get this error:

.../folly/basic $ conan lock create
ERROR: Specify the 'name' and the 'version'

When I try to do so, following the documentation, I still get the same error:

.../folly/basic $ conan lock create --name=libb --version=0.2
ERROR: Specify the 'name' and the 'version'

.../folly/basic $ conan lock create --name libb --version 0.2
ERROR: Specify the 'name' and the 'version'

Does anybody have any advice? I am sure it's something obvious, but I am new to conan.


Solution

  • The Conan lock create requires a conanfile.py file which is not present in your example. That example uses a simple conanfile.txt to install the project dependencies (Folly and OpenSSL).

    You still can generate the lock file by installing those requirements:

    $ mkdir build && cd build/
    $ conan install ..
    ...
    $ ls
    conan.lock  conanbuildinfo.cmake  conanbuildinfo.txt  conaninfo.txt  graph_info.json
    

    Also, note that you are not passing the conanfile path, as required by the command:

    .../folly/basic $ conan lock create
    ERROR: Specify the 'name' and the 'version'
    

    Instead, you should pass the path where the conanfile.py is installed:

    $ conan lock create conanfile.py
    

    However, if you want to generate a lock file only for a single reference (e.g. Folly), you can directly do it by the follow command:

    $ conan lock create --reference folly/2020.08.10.00@  -r conancenter