conan: [bug] Wrong path of vcvarsall.bat with VisualStudioBuildTools

Describe the bug

I am working in a docker container with Windows 10. OS Name: Microsoft Windows Server 2022 Datacenter OS Version: 10.0.20348 N/A Build 20348

I am downloading several tools from chocolatey: cmake 3.29.2 python 3.12.3 visualstudio2022buildtools 117.10.2.0 For visualstudio2022buildtools I additionally specify following arguments:

    --installPath "C:\Program Files\Microsoft Visual Studio\2022\BuildTools" \
    --add Microsoft.VisualStudio.Component.VC.14.29.16.11.ATL \
    --add Microsoft.VisualStudio.ComponentGroup.VC.Tools.142.x86.x64 \
    --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 \
    --add Microsoft.VisualStudio.Component.VC.ATL \
    --add Microsoft.VisualStudio.Component.Windows11SDK.22621 \
    --add Microsoft.NetCore.Component.Runtime.8.0 \
    --add Microsoft.NetCore.Component.SDK \

I create a python virtual environment and install conan 2.15.1 into it.

My conan profile:

======== Input profiles ========
Profile host:
[settings]
arch=x86_64
build_type=Debug
compiler=msvc
compiler.cppstd=20
compiler.runtime=static
compiler.runtime_type=Debug
compiler.version=194
os=Windows
[conf]
tools.cmake.cmaketoolchain:generator=Ninja

Profile build:
[settings]
arch=x86_64
build_type=Debug
compiler=msvc
compiler.cppstd=20
compiler.runtime=static
compiler.runtime_type=Debug
compiler.version=194
os=Windows
[conf]
tools.cmake.cmaketoolchain:generator=Ninja

When I run conan install, I get an error when trying to build boost/1.86.0:

-------- Installing package boost/1.86.0 (4 of 4) --------
boost/1.86.0: Building from source
boost/1.86.0: Package boost/1.86.0:3868cb107d7ee73a0ea6aa930c1efa04c34bdb20
boost/1.86.0: Building your package in C:\Users\ContainerAdministrator\.conan2\p\b\boost77f382b873394\b
boost/1.86.0: Calling generate()
boost/1.86.0: Generators folder: C:\Users\ContainerAdministrator\.conan2\p\b\boost77f382b873394\b\build-release\conan
boost/1.86.0: Generating aggregated env files
boost/1.86.0: Generated aggregated env files: ['conanbuild.bat', 'conanrun.bat']
boost/1.86.0: Calling build()
boost/1.86.0: WARN: replace_in_file didn't find pattern '/* thread_local */' in 'C:\Users\ContainerAdministrator\.conan2\p\boostcfb011e43f97d\s\src\boost\stacktrace\detail\libbacktrace_impls.hpp' file.
boost/1.86.0: WARN: replace_in_file didn't find pattern '/* static __thread */' in 'C:\Users\ContainerAdministrator\.conan2\p\boostcfb011e43f97d\s\src\boost\stacktrace\detail\libbacktrace_impls.hpp' file.
boost/1.86.0: WARN: replace_in_file didn't find pattern 'local generic-os = [ set.difference $(all-os) : aix darwin vxworks solaris osf hpux ] ;' in 'C:\Users\ContainerAdministrator\.conan2\p\boostcfb011e43f97d\s\src\tools\build\src\tools\gcc.jam' file.
boost/1.86.0: WARN: replace_in_file didn't find pattern 'local no-threading = android beos haiku sgi darwin vxworks ;' in 'C:\Users\ContainerAdministrator\.conan2\p\boostcfb011e43f97d\s\src\tools\build\src\tools\gcc.jam' file.
boost/1.86.0: WARN: Patching user-config.jam
boost/1.86.0: WARN:
using zlib : 1.3.1 : <include>"C:/Users/ContainerAdministrator/.conan2/p/b/zlibc8e77b13bfc52/p/include" <search>"C:/Users/ContainerAdministrator/.conan2/p/b/zlibc8e77b13bfc52/p/lib" <name>zlib ;
using bzip2 : 1.0.8 : <include>"C:/Users/ContainerAdministrator/.conan2/p/b/bzip271c7d8c141c8b/p/include" <search>"C:/Users/ContainerAdministrator/.conan2/p/b/bzip271c7d8c141c8b/p/lib" <name>bz2 ;
using "msvc" : 14.3 :  :
 ;
boost/1.86.0: WARN: b2 -q target-os=windows architecture=x86 address-model=64 binary-format=pe abi=ms --layout=system --user-config=C:\Users\ContainerAdministrator\.conan2\p\boostcfb011e43f97d\s\src\tools\build\user-config.jam -sNO_ZLIB=0 -sNO_BZIP2=0 -sNO_LZMA=1 -sNO_ZSTD=1 boost.locale.icu=off --disable-icu boost.locale.iconv=off --disable-iconv runtime-link=static runtime-debugging=off threading=multi visibility=hidden link=static variant=release --with-atomic --with-charconv --with-chrono --with-cobalt --with-container --with-context --with-contract --with-coroutine --with-date_time --with-exception --with-filesystem --with-graph --with-iostreams --with-json --with-locale --with-log --with-math --with-nowide --with-program_options --with-random --with-regex --with-serialization --with-stacktrace --with-system --with-test --with-thread --with-timer --with-type_erasure --with-url --with-wave toolset=msvc cxxstd=20 pch=on linkflags="" cxxflags="-fPIC" install --prefix=C:\Users\ContainerAdministrator\.conan2\p\b\boost77f382b873394\p -j2 --abbreviate-paths -d0 --debug-configuration --build-dir="C:\Users\ContainerAdministrator\.conan2\p\b\boost77f382b873394\b\build-release"
boost/1.86.0: RUN: b2 -q target-os=windows architecture=x86 address-model=64 binary-format=pe abi=ms --layout=system --user-config=C:\Users\ContainerAdministrator\.conan2\p\boostcfb011e43f97d\s\src\tools\build\user-config.jam -sNO_ZLIB=0 -sNO_BZIP2=0 -sNO_LZMA=1 -sNO_ZSTD=1 boost.locale.icu=off --disable-icu boost.locale.iconv=off --disable-iconv runtime-link=static runtime-debugging=off threading=multi visibility=hidden link=static variant=release --with-atomic --with-charconv --with-chrono --with-cobalt --with-container --with-context --with-contract --with-coroutine --with-date_time --with-exception --with-filesystem --with-graph --with-iostreams --with-json --with-locale --with-log --with-math --with-nowide --with-program_options --with-random --with-regex --with-serialization --with-stacktrace --with-system --with-test --with-thread --with-timer --with-type_erasure --with-url --with-wave toolset=msvc cxxstd=20 pch=on linkflags="" cxxflags="-fPIC" install --prefix=C:\Users\ContainerAdministrator\.conan2\p\b\boost77f382b873394\p -j2 --abbreviate-paths -d0 --debug-configuration --build-dir="C:\Users\ContainerAdministrator\.conan2\p\b\boost77f382b873394\b\build-release"
boost/1.86.0: Full command: "C:\Users\ContainerAdministrator\.conan2\p\b\boost77f382b873394\b\build-release\conan\conanbuild.bat" && b2 -q target-os=windows architecture=x86 address-model=64 binary-format=pe abi=ms --layout=system --user-config=C:\Users\ContainerAdministrator\.conan2\p\boostcfb011e43f97d\s\src\tools\build\user-config.jam -sNO_ZLIB=0 -sNO_BZIP2=0 -sNO_LZMA=1 -sNO_ZSTD=1 boost.locale.icu=off --disable-icu boost.locale.iconv=off --disable-iconv runtime-link=static runtime-debugging=off threading=multi visibility=hidden link=static variant=release --with-atomic --with-charconv --with-chrono --with-cobalt --with-container --with-context --with-contract --with-coroutine --with-date_time --with-exception --with-filesystem --with-graph --with-iostreams --with-json --with-locale --with-log --with-math --with-nowide --with-program_options --with-random --with-regex --with-serialization --with-stacktrace --with-system --with-test --with-thread --with-timer --with-type_erasure --with-url --with-wave toolset=msvc cxxstd=20 pch=on linkflags="" cxxflags="-fPIC" install --prefix=C:\Users\ContainerAdministrator\.conan2\p\b\boost77f382b873394\p -j2 --abbreviate-paths -d0 --debug-configuration --build-dir="C:\Users\ContainerAdministrator\.conan2\p\b\boost77f382b873394\b\build-release"
conanvcvars.bat: Activating environment Visual Studio 17 - amd64 - winsdk_version=None - vcvars_ver=14.4
The system cannot find the path specified.

boost/1.86.0: ERROR:
Package '3868cb107d7ee73a0ea6aa930c1efa04c34bdb20' build failed
boost/1.86.0: WARN: Build folder C:\Users\ContainerAdministrator\.conan2\p\b\boost77f382b873394\b\build-release
Traceback (most recent call last):
  File "C:\VirtualEnvironmentForConan2\Lib\site-packages\conan\internal\errors.py", line 35, in conanfile_exception_formatter
    yield
  File "C:\VirtualEnvironmentForConan2\Lib\site-packages\conan\internal\methods.py", line 35, in run_build_method
    conanfile.build()
  File "C:\Users\ContainerAdministrator\.conan2\p\boostcfb011e43f97d\e\conanfile.py", line 1167, in build
    self.run(full_command)
  File "C:\VirtualEnvironmentForConan2\Lib\site-packages\conan\internal\model\conan_file.py", line 374, in run
    raise ConanException("Error %d while executing" % retcode)
conan.errors.ConanException: Error 1 while executing

My guess is, that it is related to not finding the vcvarsall.bat file. Following two lines from my output above lead to my guess:

conanvcvars.bat: Activating environment Visual Studio 17 - amd64 - winsdk_version=None - vcvars_ver=14.4
The system cannot find the path specified.

But for sure the issue might also be somewhere else. I am looking forward to your help! And for sure I am open to provide more information as needed ๐Ÿ’Ÿ Cheers, Kilian

How to reproduce it

This is my conanfile.py:

import os
from conan import ConanFile

class MyRecipe(ConanFile):
    settings = "os", "compiler", "build_type", "arch"
    generators = "CMakeDeps"

    def requirements(self):
        self.requires("boost/1.86.0")

    def layout(self):
        self.folders.root = ".." 
        self.folders.generators = "conan"
        self.folders.imports = os.path.join(self.folders.generators, "imports")
  • I open the Visual Studio Developer Command Prompt (C:\Program Files\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvars64.bat)
  • I activate the virtual environment (for me itโ€™s located at C:\MyVenv\Scripts\Activate.ps1)
  • I call conan install:
conan install ./conanfile.py -vtrace --build missing --output-folder=out/build/x64-Release --profile:all="windows.Release64"

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

Thanks!

Could you try adding the following conf to the profile:

[conf]
tools.microsoft.msbuild:installation_path=C:/Program Files/Microsoft Visual Studio/2022/BuildTools/