conan-io / conan

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

[question] VirtualRunEnv doesn't generate PowerShell ps1 script #12624

Open fjp opened 1 year ago

fjp commented 1 year ago

Using the VirtualRunEnv generator in a conan recipe with conan 1.53 in a Windows Developer PowerShell doesn't generate ps1 scripts. Only the conanrun.bat and conanrunenv-release-x86_64.bat are generated. Is there a configuration to generate also the powershell scripts?

fjp commented 1 year ago

I just found it here: https://blog.conan.io/2022/05/18/New-conan-release-1-48.html

Setting the following in a conan windows profile creates the expected activate_run.ps1

[conf]
tools.env.virtualenv:powershell=True

I'd expected to find this conf setting in the documentation at one of the following pages but it is only found in the blog and I think in some closed issue.

fjp commented 1 year ago

@memsharded can you please share some insight, why the values in environment_run.bat are not used in the CMakePresets.json? Is there a configuration to set those values as well in the CMakePresets.json?

schwaerz commented 1 year ago

I am having a similar issue. Using the VirtualRunEnv generator. When building most packages (on Windows, from within git bash), I only get the conanrun.sh (no .bat) script. This script cannot be used like this

    def test(self):
        run("some_command", env="conanrun")

When trying to do this, I get the following error message:

'.' is not recognized as an internal or external command,
operable program or batch file.

This error message originates from the conanrun.sh script. Supposedly cmd is used to execute that script...

Then, after I finally adjusted the packages to build on Linux and Windows, I went on to the consumer package. Surprinsingly there I only get the conanrun.bat script generated (on Windows, using git bash). No conanrun.sh. I cannot figure out the reason. Neither can I run that script from within the git bash...

Is there anywhere a complete and sophisticated documentation about when conan decides to generate what files?

schwaerz commented 1 year ago

Ok, got some more insight:

In the other packages settings.os was not a requirements. Looks like if it is not set, it will generate conanrun.sh. If it is set to "Windows", it will only generate the conanrun.bat file.

Now I only have to figure out how to tell conan to generate this file when os==Windows.

spakarl commented 1 year ago

Using Powershell under Linux and no .ps1 files are generated with Conan v2 anymore. With v1 they have been generated.