Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] lock file let create fail #15801

Closed
blocksebastian opened this issue Mar 4, 2024 · 5 comments · Fixed by #15802
Closed

[bug] lock file let create fail #15801

blocksebastian opened this issue Mar 4, 2024 · 5 comments · Fixed by #15802
Assignees
Milestone

Comments

@blocksebastian
Copy link

Environment details

  • Operating System+version: Debian 12
  • Compiler+version: - not used
  • Conan version: 2.1.0
  • Python version: 3.11.2

Steps to reproduce

I want to create a package that uses source() to checkout a git repo.
At the end I want to provide python sources from local and from the git repo and cmake script files.

Steps to reproduce:

  1. conan lock create . -pr:h=profiles/none -u --lockfile-out=none.lock
  2. conan create . -pr:h=profiles/none --lockfile=none.lock --lockfile-out=none_updated.lock

Without the lockfile handling it works as expected, but our workflow requires to use lockfile.

Following conanfile.py:

import os
from conan import ConanFile
from conan.tools.files import copy, load
from conan.tools.scm import Git
from conan.errors import ConanException

class LockTest(ConanFile):
    name = "locktest"
    user = "test"
    author = "test"
    package_type = "build-scripts"
    settings = None
    options = None
    url = "https://test.com"
    description = "Lock test check"
    homepage = "https://test.com"
    topics = ("Conan", "lock")
    exports_sources = "cmake/*.cmake", "scripts/test.py", "scripts/requirements.txt", "scripts/repo/test.py"
    version = "0.5.0"

    def source(self):
        test_repo_git = Git(self)
        if not os.path.exists("test_repo"):
            test_repo_git.clone(url="/work/conan/test-repo", target="test_repo")
        else:
            print("SOURCE EXISTS")
        test_repo_git.folder = "test_repo"
        try:
            test_repo_git.checkout("testtag")
        except ConanException as e:
            test_repo_git.run("fetch")
            test_repo_git.checkout("testtag")

    def layout(self):
        """Set build folder"""
        self.folders.build = "build"
        self.folders.generators = "generators"

    def package(self):
        """copy all cmake files to the package folder"""
        copy(self, "cmake/*", src=self.source_folder, dst=self.package_folder, keep_path=True)
        copy(self, "repo/test.py", src=os.path.join(self.source_folder, "test_repo"), dst=os.path.join(self.package_folder, "scripts"), keep_path=True)
        copy(self, "scripts/test.py", src=self.source_folder, dst=self.package_folder, keep_path=True)
        copy(self, "scripts/requirements.txt", src=self.source_folder, dst=self.package_folder, keep_path=True)

    def package_info(self):
        """define the information to the consumers of this package"""

        # set path to the CMake scripts so that they can be find via find_package()
        self.cpp_info.builddirs = ["cmake"]

        # unset include/bin/lib paths, they are not needed
        self.cpp_info.includedirs = []
        self.cpp_info.bindirs = []
        self.cpp_info.libdirs = []

Logs

conan create . -pr:h=profiles/none --lockfile=test.lock  --lockfile-out=none_updated.lock
Using lockfile: '/work/conan/test-lock/test.lock'

======== Exporting recipe to the cache ========
locktest/0.5.0@test: Exporting package recipe: /work/conan/test-lock/conanfile.py
locktest/0.5.0@test: Copied 2 '.py' files: conanfile.py, test.py
locktest/0.5.0@test: Copied 1 '.txt' file: requirements.txt
locktest/0.5.0@test: Exported to cache folder: /space/conan-cache/p/locktc91dc88559167/e
locktest/0.5.0@test: Exported: locktest/0.5.0@test#7f89084684a0d344285522a023890014 (2024-03-04 07:39:46 UTC)

======== Input profiles ========
Profile host:
[settings]
[conf]
tools.build:skip_test=False
user.festo.build:run_cpptest=False

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=gnu17
compiler.libcxx=libstdc++11
compiler.version=12
os=Linux
[conf]
tools.build:skip_test=False
user.festo.build:run_cpptest=False


======== Computing dependency graph ========
ERROR: Requirement 'locktest/0.5.0@test#7f89084684a0d344285522a023890014%1709537986.1004984' not in lockfile

@memsharded memsharded self-assigned this Mar 4, 2024
@memsharded
Copy link
Member

Thanks for the report @blocksebastian

I am having a look.
I think it is related to the fact that it is a build-scripts package type, it won't happen for other package types, this seems the difference.

If you use:

$ conan create . --build-require --lockfile=none.lock --lockfile-out=none_updated.lock

It doesn't fail (with the --build-require).
I am checking exactly why, and if this can be improved.

@memsharded
Copy link
Member

Submitting an improvement in #15802, that would solve your issue.

@blocksebastian
Copy link
Author

thank you for the really fast resolution :-)

@memsharded
Copy link
Member

We can leave it open, it will be automatically closed when the PR is merged :)

Thanks for the feedback!

@memsharded memsharded reopened this Mar 4, 2024
@memsharded memsharded added this to the 2.2.0 milestone Mar 4, 2024
@memsharded
Copy link
Member

#15802 merged, this will be included in next 2.2 release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants