Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] msys2 fails to build cmake template #14041

Open
jputcu opened this issue Jun 6, 2023 · 6 comments
Open

[bug] msys2 fails to build cmake template #14041

jputcu opened this issue Jun 6, 2023 · 6 comments
Assignees

Comments

@jputcu
Copy link
Contributor

jputcu commented Jun 6, 2023

Environment details

On Windows 11, I've installed a fresh msys2 environment, using the newer ucrt64 and conan-2.0.5.

The right configuration, because I'm running conan from within ucrt64 shell.

tools.microsoft.bash:active=True
tools.microsoft.bash:subsystem=msys2
conanfile.py (dummy/0.1.0): RUN: cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="C:/Users/joris/workspace/3rdparty/dummy/build/Release/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="C:/Users/joris/workspace/3rdparty/dummy" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "C:/Users/joris/workspace/3rdparty/dummy/."
'.' is not recognized as an internal or external command,
operable program or batch file.

As far as I can deduce, the issue is with the last cmake configuration argument which is the path of the CMakeLists.txt and doesn't like that final dot: "C:/Users/joris/workspace/3rdparty/dummy/."

Steps to reproduce

Create a minimal cmake library:

> conan new cmake_lib -d name=dummy -d version=0.1.0
...
> conan build . -v trace

Logs

Profile host:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=17
compiler.libcxx=libstdc++11
compiler.version=13.1
os=Windows
[options]
boost/*:pch=False
boost/*:without_fiber=True
boost/*:without_iostreams=True
boost/*:without_stacktrace=True
[conf]
tools.microsoft.bash:active=True
tools.microsoft.bash:subsystem=msys2
tools.cmake.cmaketoolchain:generator=Ninja

Profile build:
[settings]
arch=x86_64
build_type=Release
compiler=gcc
compiler.cppstd=17
compiler.libcxx=libstdc++11
compiler.version=13.1
os=Windows
[options]
boost/*:pch=False
boost/*:without_fiber=True
boost/*:without_iostreams=True
boost/*:without_stacktrace=True
[conf]
tools.microsoft.bash:active=True
tools.microsoft.bash:subsystem=msys2
tools.cmake.cmaketoolchain:generator=Ninja
...
======== Calling build() ========
conanfile.py (dummy/0.1.0): Calling build()
conanfile.py (dummy/0.1.0): Running CMake.configure()
conanfile.py (dummy/0.1.0): RUN: cmake -G "Ninja" -DCMAKE_TOOLCHAIN_FILE="C:/Users/joris/workspace/3rdparty/dummy/build/Release/generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="C:/Users/joris/workspace/3rdparty/dummy" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "C:/Users/joris/workspace/3rdparty/dummy/."
'.' is not recognized as an internal or external command,
operable program or batch file.

Traceback (most recent call last):
  File "C:/msys64/ucrt64/lib/python3.10/site-packages/conans/errors.py", line 51, in conanfile_exception_formatter
    yield
  File "C:/msys64/ucrt64/lib/python3.10/site-packages/conans/client/conanfile/build.py", line 13, in run_build_method
    conanfile.build()
  File "C:/Users/joris/workspace/3rdparty/dummy/conanfile.py", line 43, in build
    cmake.configure()
  File "C:/msys64/ucrt64/lib/python3.10/site-packages/conan/tools/cmake/cmake.py", line 112, in configure
    self._conanfile.run(command)
  File "C:/msys64/ucrt64/lib/python3.10/site-packages/conans/model/conan_file.py", line 334, in run
    raise ConanException("Error %d while executing" % retcode)
conans.errors.ConanException: Error 1 while executing

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/msys64/ucrt64/lib/python3.10/site-packages/conan/cli/cli.py", line 171, in run
    command.run(self._conan_api, self._commands[command_argument].parser, args[0][1:])
  File "C:/msys64/ucrt64/lib/python3.10/site-packages/conan/cli/command.py", line 134, in run
    info = self._method(conan_api, parser, *args)
  File "C:/msys64/ucrt64/lib/python3.10/site-packages/conan/cli/commands/build.py", line 63, in build
    conan_api.local.build(conanfile)
  File "C:/msys64/ucrt64/lib/python3.10/site-packages/conan/api/subapi/local.py", line 97, in build
    run_build_method(conanfile, app.hook_manager)
  File "C:/msys64/ucrt64/lib/python3.10/site-packages/conans/client/conanfile/build.py", line 11, in run_build_method
    with conanfile_exception_formatter(conanfile, "build"):
  File "C:/msys64/ucrt64/lib/python3.10/contextlib.py", line 153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "C:/msys64/ucrt64/lib/python3.10/site-packages/conans/errors.py", line 66, in conanfile_exception_formatter
    _raise_conanfile_exc(exc)
  File "C:/msys64/ucrt64/lib/python3.10/site-packages/conans/errors.py", line 46, in _raise_conanfile_exc
    raise ConanExceptionInUserConanfileMethod(traceback.format_exc())
conans.errors.ConanExceptionInUserConanfileMethod: Traceback (most recent call last):
  File "C:/msys64/ucrt64/lib/python3.10/site-packages/conans/errors.py", line 51, in conanfile_exception_formatter
    yield
  File "C:/msys64/ucrt64/lib/python3.10/site-packages/conans/client/conanfile/build.py", line 13, in run_build_method
    conanfile.build()
  File "C:/Users/joris/workspace/3rdparty/dummy/conanfile.py", line 43, in build
    cmake.configure()
  File "C:/msys64/ucrt64/lib/python3.10/site-packages/conan/tools/cmake/cmake.py", line 112, in configure
    self._conanfile.run(command)
  File "C:/msys64/ucrt64/lib/python3.10/site-packages/conans/model/conan_file.py", line 334, in run
    raise ConanException("Error %d while executing" % retcode)
conans.errors.ConanException: Error 1 while executing


ERROR: Traceback (most recent call last):
  File "C:/msys64/ucrt64/lib/python3.10/site-packages/conans/errors.py", line 51, in conanfile_exception_formatter
    yield
  File "C:/msys64/ucrt64/lib/python3.10/site-packages/conans/client/conanfile/build.py", line 13, in run_build_method
    conanfile.build()
  File "C:/Users/joris/workspace/3rdparty/dummy/conanfile.py", line 43, in build
    cmake.configure()
  File "C:/msys64/ucrt64/lib/python3.10/site-packages/conan/tools/cmake/cmake.py", line 112, in configure
    self._conanfile.run(command)
  File "C:/msys64/ucrt64/lib/python3.10/site-packages/conans/model/conan_file.py", line 334, in run
    raise ConanException("Error %d while executing" % retcode)
conans.errors.ConanException: Error 1 while executing
@jputcu
Copy link
Contributor Author

jputcu commented Jun 6, 2023

Partially relates to #12877 which evolved in the same issue while trying to diagnose it.

@jputcu
Copy link
Contributor Author

jputcu commented Jun 8, 2023

Without the tools.microsoft.bash:subsystem=msys2 it works.

@memsharded
Copy link
Member

I am checking this.
The trailing . in folders doesn't seem to be the thing (did a PR for it in in #14601), but the sourcing of environment shell scripts with . conanbuild.sh && cmd ... that for some reason doesn't work correctly in msys2, I am having a look

@memsharded
Copy link
Member

I have been trying to make a basic source of a shell script work in msys2-mingw64, but it seems it just doesn't work. I cannot make something as simple as:

import subprocess

subprocess.call('. "/home/myuser/file.sh"', shell=True)

To work, while this perfectly works in Linux and msys2 (but not msys2-mingw64).

I am re-checking some assumptions about subsystems in Windows (as a side note, I find them quite problematic in general and I try to avoid them, just opting-in for the build with win_bash=True, but never running inside the subsystem (I am a Windows user)

@memsharded
Copy link
Member

Reopening, was accidentally closed by #14061, but it was not the root cause, will follow in other PRs

@realysy
Copy link

realysy commented Dec 28, 2024

While running conan install . --build=missing conan need to download and build zlib/1.2.11, I encounter a similar error: '.' is not recognized as an internal or external command

zlib/1.2.11: Generating aggregated env files
zlib/1.2.11: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh']
zlib/1.2.11: Calling build()
zlib/1.2.11: Apply patch (conan): separate static/shared builds, disable debug suffix, disable building examples
zlib/1.2.11: Apply patch (portability): fix condition for WIDECHAR usage
zlib/1.2.11: Running CMake.configure()
zlib/1.2.11: RUN: cmake -G "MinGW Makefiles" -DCMAKE_TOOLCHAIN_FILE="generators/conan_toolchain.cmake" -DCMAKE_INSTALL_PREFIX="C:/Users/tom/.conan2/p/b/zlibe1ed0e2089db7/p" -DCMAKE_SH="CMAKE_SH-NOTFOUND" -DCMAKE_POLICY_DEFAULT_CMP0091="NEW" -DCMAKE_BUILD_TYPE="Release" "C:/Users/tom/.conan2/p/b/zlibe1ed0e2089db7/b/src"
'.' is not recognized as an internal or external command,
operable program or batch file.

zlib/1.2.11: ERROR:
Package '74fce2c720f804facc619f996bab77ff99796c4d' build failed
zlib/1.2.11: WARN: Build folder C:\Users\tom.conan2\p\b\zlibe1ed0e2089db7\b\build\Release
ERROR: zlib/1.2.11: Error in build() method, line 81
cmake.configure()
ConanException: Error 1 while executing

I tried to look into the build folder in .conan, but did not find any clue of line 81 or ..

But I have done some exps of tools.microsoft.bash config in ~/.conan2/global.conf, and it appears that tools.microsoft.bash:active = True and tools.microsoft.bash:subsystem = msys2 cannot be set simultaneously if I need to build a recipe during conan install.

Exp active path subsystem Result
1 not set not set not set Success
2 TRUE not set not set Success
3 not set not set msys2 Success
4 TRUE not set msys2 Error
5 TRUE E:/msys2/msys64/usr/bin/bash.exe msys2 Error
6 TRUE /e/msys2/msys64/usr/bin/bash.exe msys2 Error

My environments (should I set tools.microsoft.bash in global.conf? ):

  • system is Win11
  • the command conan install is running in msys2/usr/bin/bash.exe
  • conan (v2.11.0) is installed by pip in a conda env of python 3.7;
  • conda is installed to Windows system directly, not in msys2
  • my conan profile:
    [settings]
    arch=x86_64
    build_type=Release
    compiler=gcc
    compiler.cppstd=gnu17
    compiler.libcxx=libstdc++11
    compiler.version=13
    os=Windows
    
    [buildenv]
    PATH+=(path)E:/msys2/msys64/ucrt64/bin
     
    [runenv]
    PATH+=(path)E:/msys2/msys64/ucrt64/bin

Finally, I set tools.microsoft.bash:active = True and tools.microsoft.bash:subsystem = msys2 in ~/.conan2/global.conf is for the reason that I want conan install to produce conanrun.sh instead of conanrun.bat in the build folder of my project, and it does work (I am using msys2/usr/bash.exe, not cmd.exe or powershell, so .sh files are better for me than .bat files).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants