conan-io / conan

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

[question] How to update a reference in a lockfile? #16636

Open maksim-petukhov opened 2 months ago

maksim-petukhov commented 2 months ago

What is your question?

Hi. I started to use lockfiles and I have my libraries locked inside conan.lock (I used conan install ... -lockfile-out=conan.lock to create it and didn't edit it or used conan lock ... commands on it). Among them - qt/5.15.10#3c0bbf763b778e7b7fc6663eea043447 which I want to update. I've added some patches, built the package and now I have a new revision of it (qt/5.15.10#64e483ec8cfebb74e03da891c848e5a4) in our Artifactory. I also have a new requirement in my conanfile which I want to lock (let's say cpython). What I've tried so far:

  1. conan install . --profile:host ... --profile:build ... -o=&:my_option=my_value --lockfile-partial --lockfile-out=conan.lock --update returns ERROR: Requirement 'cpython/...' not in lockfile. But the documentation clearly states --lockfile-partial Do not raise an error if some dependency is not found in lockfile. Why do I have an error then?

  2. On the other hand this doesn't return an error (I moved --lockfile-partial to the beginning) and it adds cpython to the lockfile, though it doesn't update a reference of a qt in a lockfile: conan install . --lockfile-partial --profile:host ... --profile:build ... -o=&:my_option=my_value --lockfile-out=conan.lock --update. Again, according documentation --update Will install newer versions and/or revisions in the local cache for the given reference, or all in case no argument is supplied. and I believe that's what I want.

    In the logs I have:

    ```
    ======== Computing dependency graph ========
    Graph root
        conanfile.py: some\path\to\conanfile.py
    Requirements
        qt/5.15.10#3c0bbf763b778e7b7fc6663eea043447 - Cache
    ...
    ======== Computing necessary packages ========
    Requirements
       qt/5.15.10#3c0bbf763b778e7b7fc6663eea043447:fa0e758b93c42da18a2a0ee6f099fb6c0047624d#4e0a88d78229da2fd9a3835c25388f79 - Cache
    ```
  3. If I specify that I want to update qt it also doesn't update a reference of a qt in a lockfile: conan install . --lockfile-partial --profile:host ... --profile:build ... -o=&:my_option=my_value --lockfile-out=conan.lock --update=qt.

    Same logs.

So, how do I update the reference of qt in the lockfile to the latest available in the remote revision of qt?

conan 2.5.0

Have you read the CONTRIBUTING guide?

AbrilRBS commented 2 months ago

Have you seen conan lock update? It's available from Conan 2.5.0, and is meant to solve cases like this where it's a bit confusing as to how to update a specific reference :)

maksim-petukhov commented 2 months ago

Have you seen conan lock update? It's available from Conan 2.5.0, and is meant to solve cases like this where it's a bit confusing as to how to update a specific reference :)

I've seen it. From the docs The command will replace existing locked references that matches the same package name with the provided argument values. I do not want to provide anything by hand. I want conan to get latest revision of qt from a remote (in my case it is 64e483ec8cfebb74e03da891c848e5a4), to put it cache and then update the lockfile with the new reference

maksim-petukhov commented 2 months ago

@memsharded could you please comment on this issue?

memsharded commented 2 months ago

I've seen it. From the docs The command will replace existing locked references that matches the same package name with the provided argument values. I do not want to provide anything by hand. I want conan to get latest revision of qt from a remote (in my case it is 64e483ec8cfebb74e03da891c848e5a4), to put it cache and then update the lockfile with the new reference

The lockfiles are actually locking things, this is its main purpose. Trying to have both packages locked and updated are contradictory goals.

If you want to get some specific package version "unlocked", then you can remove it from the lockfile with conan lock remove. Then, the next conan lock create will resolve to the latest one, or if using other command like conan install, then you can provide --lockfile-partial argument to let it resolve even if it is not in the lockfile.

memsharded commented 2 months ago

Any further question here @maksim-petukhov?