conan icon indicating copy to clipboard operation
conan copied to clipboard

[bug] self.win_bash and msys2, internal commands not found

Open lasote opened this issue 3 years ago • 3 comments

While testing this PR: https://github.com/conan-io/conan/pull/12095

I saw that I couldn't run any command belonging to msys2 (installed packages there) located in /usr/bin, but there were tests that work because they use the @pytest.mark.tool_msys2 that is putting the C:/msys64/usr/bin in the path in the conftest.py.

I think that is very confusing because a recipe trying to run a command like autoconf in msys2 doesn't find it, nevertheless, we have 2 conf to "set up" the environment: tools.microsoft.bash:subsystem and tools.microsoft.bash:path. So we could:

  1. Ignore this and expect the user to have the c:/mysys2/../usr/bin in the path.
  2. Somehow declare the PATH to the folder "/usr/bin" before running the command
  3. Have a conf for that path? Looks like too much.

PD: I haven't tested it this happens in other subsystems. PD: This is failing in develop2 too.

lasote avatar Sep 14 '22 08:09 lasote

@lasote I have a feeling it might be related to: https://github.com/conan-io/conan/issues/11980 (which has a proposed fix: https://github.com/conan-io/conan/issues/11980) or more likely https://github.com/conan-io/conan/issues/11986

jellespijker avatar Sep 14 '22 13:09 jellespijker

Yes, thanks, https://github.com/conan-io/conan/issues/11986 is the one. I see that you closed the issue because of using of msys2 conan center package. But I still think there is a bug in Conan, working with a local msys2 installation should also work.

lasote avatar Sep 14 '22 14:09 lasote

Agreed. My proposed solution was making sure the parent directory of the bash.exe from the conf value was added to the msys2 generated file. But that caused some issue at the time: https://github.com/conan-io/conan/pull/11987

jellespijker avatar Sep 14 '22 14:09 jellespijker

I am checking this, and this works:

[settings]
arch=x86_64
os=Windows
compiler=gcc
compiler.version=6
compiler.libcxx=libstdc++11

[conf]
tools.microsoft.bash:subsystem=msys2
tools.microsoft.bash:path=C:/ws/msys64/usr/bin/bash.exe
tools.env.virtualenv:auto_use=True

[buildenv]
PATH=+(path)C:/ws/msys64/usr/bin
from conan import ConanFile


class HelloConan(ConanFile):
    name = "hello"
    version = "0.1"

    # Binary configuration
    settings = "os", "arch"

    win_bash = True

    def build(self):
        self.run("ar")

The winbash might be redundant here, of course, not strictily necessary

memsharded avatar Nov 03 '22 12:11 memsharded