conan-io / conan

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

[bug] `conan source` does not actually get `global.conf`'s `core.` confs #16555

Closed AbrilRBS closed 4 months ago

AbrilRBS commented 4 months ago

Describe the bug

While helping @ErniGH with an issue while trying to fetch glib's source with conan source, we noticed that the command was not respecting the core.sources:download_cache conf.

In fact, https://github.com/conan-io/conan/blob/develop2/conan/api/subapi/local.py#L78 comment is a lie, because only tool and user confs are propagated when eventually calling rebase_conf_definition in the newly created profile.

I'm not sure then how this has ever worked 🤔

How to reproduce it

This test currently fails

def test_source_method_access_to_globalconf():
    c = TestClient(light=True)
    c.save({"conanfile.py": textwrap.dedent("""
    from conan import ConanFile

    class Pkg(ConanFile):
        name = "pkg"
        version = "0.1"
        def source(self):
            self.output.info(f'Backup download cache: {self.conf.get("core.sources:download_cache")}')
    """)})
    c.save_home({"global.conf": "core.sources:download_cache=foobar"})
    c.run("source .")
    assert "Backup download cache: foobar" in c.out
AbrilRBS commented 4 months ago

Closing as solved, the issue arose in an old Conan version. The global conf is properly propagated to the tool helpers via the conan_helper mechanisim, it's just that the conanfile's conf which does not get it, which we think is "a feature not a bug" :)