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

Depend on a library and override upstream requirements #4779

jgsogo opened this Issue Mar 20, 2019 · 0 comments


1 participant
Copy link

jgsogo commented Mar 20, 2019

After implementing #4473 (config variable general.error_on_override), the user can turn any non-explicit dependency override into an error, but there is no way in Conan to declare at the same time that a package:

  1. depends on a reference
  2. wants to override upstream conflicts

Something like the following in a recipe fails with a Duplicated requirement error:

class Lib(ConanFile):
    requires = (("Hello1/0.1@lasote/stable"), 
                ("Hello0/0.1@lasote/stable", "override"),

I suggest the following test (taken from #4771, here: conans/test/functional/graph/

class ConflictDiamondTest(unittest.TestCase):
    conanfile = textwrap.dedent("""
        from conans import ConanFile

        class HelloReuseConan(ConanFile):
            name = "%s"
            version = "%s"
            requires = %s

    def _export(self, name, version, deps=None, export=True):
        deps = ", ".join(['"%s"' % d for d in deps or []]) or '""'
        conanfile = self.conanfile % (name, version, deps)
        files = {CONANFILE: conanfile}, clean_first=True)
        if export:
  "export . lasote/stable")

    def setUp(self):
        self.client = TestClient()
        self._export("Hello0", "0.1")
        self._export("Hello0", "0.2")
        self._export("Hello1", "0.1", ["Hello0/0.1@lasote/stable"])
        self._export("Hello2", "0.1", ["Hello0/0.2@lasote/stable"])


    def test_override_explicit_and_depend(self):
        """ ...
        with environment_append({'CONAN_ERROR_ON_OVERRIDE': "True"}):
            conanfile = self.conanfile % ("Hello3", "0.1",
                                          '(("Hello1/0.1@lasote/stable"), '
                                          '("Hello2/0.1@lasote/stable"), '
                                          '("Hello0/0.1@lasote/stable", "override"),
  {CONANFILE: conanfile})
  "install . --build missing")
            self.assertIn("Hello2/0.1@lasote/stable requirement Hello0/0.2@lasote/stable overridden"
                          " by Hello3/0.1@None/None to Hello0/0.1@lasote/stable",

            json_file = os.path.join(self.client.current_folder, 'tmp.json')
  'info . --only=requires --json="{}"'.format(json_file))
            data = json.loads(load(json_file))
            hello0 = data[0]
            self.assertEqual(hello0["reference"], "Hello0/0.1@lasote/stable")
                                 sorted(["Hello2/0.1@lasote/stable", "Hello1/0.1@lasote/stable", "Hello3/0.1@None/None"]))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.