Closed boussaffawalid closed 1 year ago
Hi @boussaffawalid
Just to be sure, is that happening even adding os.subsystem=msys2
into your profile?
@franramirez688 I tried to add os.subsystem=msys2
to my profile as follow
[settings]
os=Windows
os_build=Windows
os.subsystem=msys2
arch=x86_64
arch_build=x86_64
compiler=Visual Studio
compiler.version=16
compiler.runtime=MD
build_type=RelWithDebInfo
[options]
[tool_requires]
*: ninja/1.10.2-gb935597@pmi/stable
[env]
CC=cl.exe
CXX=cl.exe
[conf]
tools.cmake.cmaketoolchain:generator=Visual Studio 16 2019
but I got this error
ninja/1.10.2-gb935597@pmi/stable: WARN: Can't find a 'ninja/1.10.2-gb935597@pmi/stable' package for the specified settings, options and dependencies:
- Settings: arch=x86_64, build_type=RelWithDebInfo, compiler=Visual Studio, compiler.runtime=MD, compiler.version=16, os=Windows, os.subsystem=msys2
it seems like os.subsystem
is not included in the package id
I think it is because running in bash is not the same as having a os.subsystem
different binary. That subsetting is intended for having specific different binaries for msys/cygwin platforms. In this case, it seems that you want to run in bash, but the build is still a native Windows binary, so no os.subsystem
should be defined.
Instead, the conf
s:
Is what will be used to tell Conan that it is running bash on that specific subsystem, and Conan should act accordingly and generate .sh files
Yeah, that's fine. It only means that the precompiled package does not exist for your current settings (see this Troubleshooting section). You'll have to add the --build missing
option into your conan install
or conan create
command.
@memsharded I'm running native windows binary, but using git bash to run commands/scripts instead of windows cmd.exe. I tired all of options below but nothing worked, only conanrun.bat are being generated
export CONAN_BASH_PATH="C:\\Program Files\\Git\\bin\\bash.exe"
export CONAN_BASH_PATH="C:/Program Files/Git/bin/bash.exe"
export CONAN_BASH_PATH=C:/Program Files/Git/bin/bash.exe
export CONAN_BASH_PATH=/C/Program Files/Git/bin/bash.exe
[conf]
tools.microsoft.bash:path="C:/Program Files/Git/bin/bash.exe"
[conf]
tools.microsoft.bash:path="C:/Program Files/Git/bin/bash.exe"
[conf]
tools.microsoft.bash:path=/C/Program Files/Git/bin/bash.exe
[conf]
tools.microsoft.bash:path="C:\Program Files\Git\bin\bash.exe"
But aren't you defining tools.microsoft.bash:subsystem
too? That is the main one to be defined, as it conditions the path format and other stuff to be used
I tried that as well but still the same issue, here are some of the combinations I tired
[conf]
tools.cmake.cmaketoolchain:generator=Ninja
tools.microsoft.bash:subsystem=msys
tools.microsoft.bash:path=C:/Program Files/Git/bin/bash.exe
[conf]
tools.cmake.cmaketoolchain:generator=Ninja
tools.microsoft.bash:subsystem=msys2
tools.microsoft.bash:path=C:/Program Files/Git/bin/bash.exe
[conf]
tools.cmake.cmaketoolchain:generator=Ninja
tools.microsoft.bash:subsystem=cygwin
tools.microsoft.bash:path=C:/Program Files/Git/bin/bash.exe
[conf]
tools.cmake.cmaketoolchain:generator=Ninja
tools.microsoft.bash:subsystem=cygwin
tools.microsoft.bash:path="C:/Program Files/Git/bin/bash.exe"
Oh, I think what it could be. Have you added the win_bash = True
to the recipe?
This is necessary to enable the Windows subsystem bash. I have tried it, and I managed to get .sh files with the above conf (the first one)
still I cannot get the sh scripts even with win_bash = True
I will share a git repo with a basic example to reproduce the issue.
@memsharded here is a basic example to reproduce the issue https://github.com/boussaffawalid/conan_issue_10900
I see. It seems the issue is that you are using VirtualRunEnv
. As it is a Windows native binary, it doesn't need the subsystem, and its target run environment is the Windows native machine. So it is generating a .bat according to the target run environment. It works when you are using VirtualBuildEnv
and using tool_requires
dependencies.
For Conan VirtualRunEnv
to generate a .sh for the run environment, it should be targeting the subsystem environment, like being a msys2 or cygwin executable.
Maybe it would be good to understand a bit better what you are trying to accomplish, and your setup. Conan so far models 2 ways of working:
bash
for running the build. This is the conf
way, and it doesn't need to run Conan inside bash, it can perfectly run in cmd
terminal, and it will still use the bash
terminal for the build whenever necessary. But other tasks, as running executables are still done in the native Windows. (with .bat files)os.subsystem
setting definition (they are different binaries than the native ones). Conan must run inside the subsystem directly, not natively.Our use case:
conanrun.sh
for native windows, so that we can start executable directly from bash.exe without the need to switch to windows cmd.exe.Just in case: I think explicitly generating the file is always possible with something like:
def generate(self):
vrun = VirtualRunEnv(self)
vvars = vrun.vars()
vvars.save_script("myvars.sh")
As long as the file has the .sh extension, it will use the .sh output format and not bat.
Did you get to solve the issue @boussaffawalid ? Or still, having problems?
@franramirez688 I just tested it and it works as charm! Thanks
Doing some more testing I found another issue.
here is what is in my conanrunenv.sh
export PATH="C:\.conan\ccd9f5\1\bin;C:\.conan\04a518\1\bin;C:\.conan\3de530\1\bin;$PATH"
This wont work from git bash, it has to be something like
export PATH="C:\.conan\ccd9f5\1\bin":"C:\.conan\04a518\1\bin":"C:\.conan\3de530\1\bin":"$PATH"
This is true @franramirez688 , the code inside has a comment:
if subsystem is None and not scope.startswith("build"): # "run" scope do not follow win_bash
return WINDOWS
Most of the internals are not designed to run inside bash, but without not targeting a subsystem.
The Virtual*Env
generators should just generate all 3 flavors of scripts, like they did with the v1 generators. On Windows especially, one can end up using cmd, bash and powershell, while on *nix powershell is also used quite a bit.
The VirtualEnv generators should just generate all 3 flavors of scripts, like they did with the v1 generators. On Windows especially, one can end up using cmd, bash and powershell, while on nix powershell is also used quite a bit.
Even if it generated the 3 flavors, now Conan relies on using those files for the injection of the environment to commands. So defining which system/flavor is using is necessary. Generating the 3 only delays the decision, and introduces the chance of discrepancies, like working in the user side because the user manually uses one, but then failing at conan create
because Conan uses a different one. It would be preferred that the generated and used file is selected consistently.
I don't think someone who uses Conan just to fetch dependencies and spit out config files to make those importable wants to use conan create
or other machinery provided by Conan. In fact, it looks like someone who wants to use Conan as such needs to do more upfront Conan specific plumbing with v2.
I don't think someone who uses Conan just to fetch dependencies and spit out config files to make those importable wants to use conan create or other machinery provided by Conan. In fact, it looks like someone who wants to use Conan as such needs to do more upfront Conan specific plumbing with v2.
Even if you don't want to, it is necessary to be consistent, otherwise it is a mess for users wanting to create packages. And when the configuration files need to be aware of things like subsystem, the configuration is necessary. It is not enough to generate .sh files, it is necessary to know which subsystem is targeting (msys, cygwin...) because the paths do change. Conan v2 is indeed more explicit, it will no longer try to guess things, it has always been a very problematic behavior of Conan 1.X, and a source of many support tickets and users struggling. So now the idea is that Conan 2.0 will generate a .sh script for you, for example if you tell it "I am using msys2, and I need a .sh" file for it. It might be via a -s os.subsystem=msys2
or maybe with -c tools.build:subsystem=cygwin
, depending on the use case. And it is totally possible that we are missing some cases that we haven't contemplated yet in the new model, but for sure, Conan 2.0 will require the user to tell what it wants. If you are in Windows, and target Visual compiler, and don't specify anything else, it will likely resort the the default of generating a .bat for you and not a .sh, because the likelihood that the .sh that it will be guessing is not right is not low.
I guess what I'm missing is very clear step-by-step guides for scenarios like the case I presented (just using Conan to fetch deps and spit out the files for CMake to use) and how get more involved with Conan.
It would be terrific if I could just link people wishing to contribute to a Conan and CMake managed project in the contribution docs to a Conan managed documentation page that describes setting up a profile, toolchain settings, etc, to the point where they can just conan install .
and carry on with their day.
I guess what I'm missing is very clear step-by-step guides for scenarios like the case I presented (just using Conan to fetch deps and spit out the files for CMake to use) and how get more involved with Conan.
Yes, that is true. We are in the process of creating whole new docs for Conan 2.0, and they are more tutorial-like, with more examples, etc.
Hi all,
I am investigating/proposing in https://github.com/conan-io/conan/pull/11066, to define a new conf that says "I am already running inside bash", and that would trigger the creation of .sh files, both for "buildenv" and "runenv"
Even if you don't want to, it is necessary to be consistent, otherwise it is a mess for users wanting to create packages. And when the configuration files need to be aware of things like subsystem, the configuration is necessary. It is not enough to generate .sh files, it is necessary to know which subsystem is targeting (msys, cygwin...) because the paths do change. Conan v2 is indeed more explicit, it will no longer try to guess things, it has always been a very problematic behavior of Conan 1.X, and a source of many support tickets and users struggling.
So how can someone build their own in-source recipe with "conan install . ; conan source ." in msys (and also probably "conan build ." and then switch to MSVC to compile and debug? We are still pumping out the .sln files, right? Won't those be building on the DOS MSVC Command Prompt environment?
I don't know all the problems you are talking about (apart from the generation-of-scripts), but it seems to be pretty unavoidable that you have to be able to switch between different path-environments to use the full set of tools available on Windows.
Actually in my situation, I'd be happy with Windows paths in a environment.sh file. I'm in msys, I'm using bash, but building Windows-native - ie does not need to run on the msys subsystem.
This already behaves this way when you run "conan install . -g VirtualRunEnv" -- you get the .sh files only. So I can't use that build and switch to a DOS / MSVC environment to continue working there ...
It is only when you run "conan install package/1.0@ -g VirtualRunEnv" that you get the .bat files instead of the .sh files.
I got VirtualRunEnv to finally work, but I had to: add to the profile:
And to the recipe: win_bash = True
It is very clunky compared to the old virtualenv, I would have to edit the recipe, adjust the profile, "conan install" and then finally be able to use (eg) the DOS prompt.
I hope #11066 makes this easier ...
https://github.com/conan-io/conan/pull/12178 merged, this will be in next 1.54
Hello,
I'm trying to switch to the new VirtualRunEnv instead of virtualrunenv, but I've noticed that the new generator does not generate
sh
scripts for windows when conan command is being called frombash
(git bash or MSYS2)This was not the case before with the old virtualrunenv generator. Not sure if this is an intended behavior or a bug, but it would be really nice to support sh scripts for windows as well.
Thanks.