conan
conan copied to clipboard
[bug] tools.env.virtualenv:powershell=True prevents program from compiling
Environment details
- Operating System+version: Windows 10 22H2
- Compiler+version: clang-cl 16.0.5
- Conan version: 2.0.11
- Python version: 3.11.5
Steps to reproduce
- Use the following profile:
[settings]
arch=x86_64
build_type=Release
compiler=clang
compiler.version=16
compiler.cppstd=23
compiler.runtime=dynamic
compiler.runtime_version=v143
os=Windows
[conf]
tools.cmake.cmaketoolchain:generator=Ninja Multi-Config
tools.env.virtualenv:powershell=True
- Run
conan new cmake_lib -d name=hello -d version=1.0 - Try to build it with
conan build .
This issue must be related to (or consequence of) https://github.com/conan-io/conan/issues/14765/
Logs
======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=clang
compiler.cppstd=23
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.runtime_version=v143
compiler.version=16
os=Windows
[conf]
tools.cmake.cmaketoolchain:generator=Ninja Multi-Config
tools.env.virtualenv:powershell=True
Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=clang
compiler.cppstd=23
compiler.runtime=dynamic
compiler.runtime_type=Release
compiler.runtime_version=v143
compiler.version=16
os=Windows
[conf]
tools.cmake.cmaketoolchain:generator=Ninja Multi-Config
tools.env.virtualenv:powershell=True
======== Computing dependency graph ========
Graph root
conanfile.py (hello/1.0): D:\Documents\CAST\test\conanfile.py
======== Computing necessary packages ========
======== Installing packages ========
======== Installing packages ========
======== Finalizing install (deploy, generators) ========
conanfile.py (hello/1.0): Calling generate()
conanfile.py (hello/1.0): Generators folder: D:\Documents\CAST\test\build\generators
conanfile.py (hello/1.0): CMakeToolchain generated: conan_toolchain.cmake
conanfile.py (hello/1.0): Preset 'conan-default' added to CMakePresets.json. Invoke it manually using 'cmake --preset conan-default' if using CMake>=3.23
conanfile.py (hello/1.0): If your CMake version is not compatible with CMakePresets (<3.23) call cmake like: 'cmake <path> -G "Ninja Multi-Config" -DCMAKE_TOOLCHAIN_FILE=D:\Documents\CAST\test\build\generators\conan_toolchain.cmake -DCMAKE_POLICY_DEFAULT_CMP0091=NEW'
conanfile.py (hello/1.0): CMakeToolchain generated: CMakePresets.json
conanfile.py (hello/1.0): CMakeToolchain generated: ..\..\CMakeUserPresets.json
conanfile.py (hello/1.0): Generating aggregated env files
conanfile.py (hello/1.0): Generated aggregated env files: ['conanbuild.bat', 'conanbuild.ps1', 'conanrun.ps1']
======== Calling build() ========
conanfile.py (hello/1.0): Calling build()
conanfile.py (hello/1.0): Running CMake.configure()
conanfile.py (hello/1.0): RUN: cmake -G "Ninja Multi-Config" -DCMAKE_TOOLCHAIN_FILE="D:/Documents/CAST/test/build/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="D:/Documents/CAST/test" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" "D:\Documents\CAST\test"
conanvcvars.bat: Activating environment Visual Studio 17 - amd64 - vcvars_ver=14.3
[vcvarsall.bat] Environment initialized for: 'x64'
-- Using Conan toolchain: D:/Documents/CAST/test/build/generators/conan_toolchain.cmake
-- Conan toolchain: C++ Standard 23 with extensions OFF
-- Conan toolchain: Setting BUILD_SHARED_LIBS = OFF
-- The CXX compiler identification is MSVC 19.37.32824.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe - broken
CMake Error at D:/Documents/CAST/python3.11/Lib/site-packages/cmake/data/share/cmake-3.27/Modules/CMakeTestCXXCompiler.cmake:60 (message):
The C++ compiler
"C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.37.32822/bin/Hostx64/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: 'D:/Documents/CAST/test/build/CMakeFiles/CMakeScratch/TryCompile-0w0knt'
Run Build Command(s): D:/Documents/CAST/python3.11/Scripts/ninja.exe -v cmTC_6f395
ninja: error: CMakeFiles\common.ninja:23: loading 'CMakeFiles\rules.ninja': Le fichier spécifié est introuvable.
include CMakeFiles\rules.ninja
^ near here
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
-- Configuring incomplete, errors occurred!
*********************************************************
Recipe 'conanfile.py (hello/1.0)' cannot build its binary
It is possible that this recipe is not Conan 2.0 ready
If the recipe comes from ConanCenter, report it at https://github.com/conan-io/conan-center-index/issues
If it is your recipe, check if it is updated to 2.0
*********************************************************
ERROR: conanfile.py (hello/1.0): Error in build() method, line 44
cmake.configure()
ConanException: Error 1 while executing
Hi @Todiq !
Sorry about the delay. Could you check if it's still failing with the latest Conan release (2.0.16)?
Hello @juansblanco,
No worries. I managed to reproduce it with 2.0.16.
I have 2 profiles:
- windows-clang-debug:
[settings]
arch={{detect_api.detect_arch()}}
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.version=193
os=Windows
&:build_type=Debug
&:compiler=clang
&:compiler.cppstd=17
&:compiler.version=16
[buildenv]
&:PATH=+(path)C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/Llvm/bin/
[conf]
&:tools.build:exelinkflags=["-fuse-ld=lld"]
&:tools.build:sharedlinkflags=["-fuse-ld=lld"]
&:tools.build:skip_test=False
&:tools.env.virtualenv:powershell=True
&:tools.cmake.cmaketoolchain:generator=Ninja Multi-Config
- windows-msvc-debug:
[settings]
arch={{detect_api.detect_arch()}}
build_type=Release
compiler=msvc
compiler.cppstd=14
compiler.runtime=dynamic
compiler.version=193
os=Windows
&:build_type=Debug
&:compiler.cppstd=17
[conf]
&:tools.build:skip_test=False
&:tools.env.virtualenv:powershell=True
&:tools.cmake.cmaketoolchain:generator=Ninja Multi-Config
This issue happens whenever I first run conan build .\project --profile:all "windows-clang-debug", then conan build .\core --profile:all "windows-msvc-debug"
It does not come from an overlapping of build folders. In fact, here my layout() method:
def layout(self):
self.folders.build_folder_vars = ["settings.os", "settings.compiler", "settings.compiler.version", "settings.arch"]
cmake_layout(self)
Which means I have both project\build\windows-clang-16-x86_64 and project\build\windows-msvc-193-x86_64 in my workspace.
Please tell me if you need further information
I confirm this keeps happening on 2.4.1 when switching between generators (MSBuild & Ninja)
Hi @Todiq
I am trying to reproduce, but no success so far. I am running in a regular cmd windows, not a powershell one, I don't know if this could be a difference.
The profiles above are not really changing generators in both cases clang/msvc it is always using Ninja Multi-Config, am I missing something?
Hi @Todiq any update here? I couldn't reproduce and it wasn't very clear the generators as always using Ninja Multi-Config
@memsharded
I’ll try to reproduce it. But it’s been a random issue for me. I’m gonna give it a shot before 2.5.0 goes out
@memsharded
I have been unable to reproduce it consistently. It always happens randomly.
The quick fix that always works is to kill the powershell that was running the conan build and start with a fresh one.
If that can help, I am using Visual Studio 2022 Developer PowerShell v17.10.5 and use conan from a virtualenv:
version: 2.6.0
conan_path: D:\venv\Scripts\conan
python
version: 3.9.13
sys_version: 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)]
sys_executable: D:\venv\Scripts\python.exe
is_frozen: False
architecture: AMD64
system
version: 10.0.22631
platform: Windows-10-10.0.22631-SP0
system: Windows
release: 10
cpu: Intel64 Family 6 Model 186 Stepping 3, GenuineIntel
My msvc profile is now the following:
{% set os = detect_api.detect_os() %}
{% if os == "Windows" %}
{% set compiler, version, compiler_exe = detect_api.detect_msvc_compiler() %}
{% else %}
{% set compiler = "msvc" %}
{% set version = "194" %}
{% endif %}
[settings]
arch={{detect_api.detect_arch()}}
build_type=Release
compiler={{compiler}}
compiler.cppstd=17
compiler.runtime=dynamic
compiler.version={{version}}
os=Windows
cast*/*:compiler.cppstd=17
[conf]
{% if os == "Windows" %}
pkg*/*:tools.env.virtualenv:powershell=True
{% endif %}
pkg*/*:tools.cmake.cmaketoolchain:generator=Ninja Multi-Config
pkg*/*:tools.cmake.cmake_layout:build_folder_vars = ["settings.os", "settings.compiler", "settings.compiler.version", "settings.arch"]
Just happened after deleting the build folder and the CMakeUserPreset.json file:
conanvcvars.bat: Activating environment Visual Studio 17 - amd64 - winsdk_version=None - vcvars_ver=14.4
[vcvarsall.bat] Environment initialized for: 'x64'
-- Using Conan toolchain: D:/core/build/windows-msvc-194-x86_64/generators/conan_toolchain.cmake
-- Conan toolchain: Setting CMAKE_MSVC_RUNTIME_LIBRARY=$<$<CONFIG:Release>:MultiThreadedDLL>
-- Conan toolchain: C++ Standard 17 with extensions OFF
-- Conan toolchain: Setting BUILD_SHARED_LIBS = ON
-- The CXX compiler identification is MSVC 19.40.33813.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - broken
CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Professional/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.28/Modules/CMakeTestCXXCompiler.cmake:60 (message):
The C++ compiler
"C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe"
is not able to compile a simple test program.
It fails with the following output:
Change Dir: 'D:/core/build/windows-msvc-194-x86_64/CMakeFiles/CMakeScratch/TryCompile-msi59b'
Run Build Command(s): D:/venv/Scripts/ninja.exe -v cmTC_754d3
ninja: error: CMakeFiles\common.ninja:23: loading 'CMakeFiles\rules.ninja': Le fichier spécifié est introuvable.
include CMakeFiles\rules.ninja
^ near here
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:3 (project)
-- Configuring incomplete, errors occurred!
ERROR: conanfile.py (castcore/0.1): Error in build() method, line 130
cmake.configure()
ConanException: Error 1 while executing
I though it would only happen when there is a conflict in the build folder between two subfolders (one generated with Ninja, the other with Ninja Multi-Config), but apparently not
Hi @Todiq
I have been re-checking this ticket. I have used your latest profile, removed the "build" and "CMakeUserPresets.json", etc, but couldn't make it fail
Do you have any update about this? Is this still happening? Can you reproduce it, even if randomly, with a conan new cmake_lib -d name=pkg template project?
@memsharded
It happened again once last week, after a few months without any issues. The error may simply come from ninja. I haven't tried with a template project just yet though.