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

[question] Windows bash handling in conancenter recipes #20166

Open
SpaceIm opened this issue Sep 27, 2023 · 1 comment
Open

[question] Windows bash handling in conancenter recipes #20166

SpaceIm opened this issue Sep 27, 2023 · 1 comment
Labels
question Further information is requested

Comments

@SpaceIm
Copy link
Contributor

SpaceIm commented Sep 27, 2023

What is your question?

Currently in conan v2 recipes, we have this logic in build requirements when a bash is needed and build machine is Windows:

    @property
    def _settings_build(self):
        return getattr(self, "settings_build", self.settings)

    def build_requirements(self):
        if self._settings_build.os == "Windows":
            self.win_bash = True
            if not self.conf.get("tools.microsoft.bash:path", check_type=str):
                self.tool_requires("msys2/cci.latest")

I just realized that this logic doesn't properly handle consumers running conan from a bash terminal on Windows and setting tools.microsoft.bash:active=True (this conf didn't exist AFAIK when we have implemented this logic in conancenter recipes) and tools.microsoft.bash:subsystem. Indeed in this case tools.microsoft.bash:path is useless and not used at all in conan v2 client, so there is no reason for consumers to set this conf.
But if tools.microsoft.bash:path is not set, current conancenter recipes will download msys2 recipe and inject it in build context (and override conf of users?) while it's useless and could even lead to conflicts and weird behavior.

So I guess we could replace this logic by:

    @property
    def _settings_build(self):
        return getattr(self, "settings_build", self.settings)

    def build_requirements(self):
        if self._settings_build.os == "Windows":
            self.win_bash = True
            if not self.conf.get("tools.microsoft.bash:subsystem", check_type=str):
                self.tool_requires("msys2/cci.latest")

@memsharded what do you think?

or maybe more explicit?

    @property
    def _settings_build(self):
        return getattr(self, "settings_build", self.settings)

    def build_requirements(self):
        if self._settings_build.os == "Windows":
            self.win_bash = True
            if not (self.conf.get("tools.microsoft.bash:subsystem", check_type=str) and \
                    (self.conf.get("tools.microsoft.bash:active", default=False, check_type=bool) or \
                     self.conf.get("tools.microsoft.bash:path", check_type=str))):
                self.tool_requires("msys2/cci.latest")
@SpaceIm
Copy link
Contributor Author

SpaceIm commented Sep 11, 2024

@memsharded what is your opinion (I've remembered this issue while answering to conan-io/conan#16963)?

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

No branches or pull requests

1 participant