Open System-Arch opened 1 year ago
As the instrumentation above shows, when running in a Git Bash shell on Windows, the environment variable ORIGINAL_PATH gets set at window creation time. The presence of this environment variable appears to prevent the MSYS2_PATH_TYPE=inherit behavior for operating correctly. I worked around this issue by unsetting this environment variable before calling Conan, but it might make sense to explicitly unset ORIGINAL_PATH by setting to empty in the msys2_mode.bat batch file used to launch commands with Bash in subsystems.py.
Hi @System-Arch
Have you defined the necessary conf
? From conan config list
:
tools.microsoft.bash:active: If Conan is already running inside bash terminal in Windows
tools.microsoft.bash:path: The path to the shell to run when conanfile.win_bash==True
tools.microsoft.bash:subsystem: The subsystem to be used when conanfile.win_bash==True. Possible values: msys2, msys, cygwin, wsl, sfu
To specify Conan that it is running inside a bash, it is necessary to tell it with the active
configuration, so Conan will not attempt to wrap in an extra bash -c
Hi @memsharded, Thanks for your quick reply. I tried setting tools.microsoft.bash:active=True alone and with tools.microsoft.bash:subsystem=msys2 as well as tools.microsoft.bash:path=C:\Program Files\Git\bin\bash.exe, but these all caused an even more severe error of the form:
-------- Finalizing install (deploy, generators) -------- conanfile.py (m4/1.4.19): Calling generate() conanfile.py (m4/1.4.19): Aggregating env generators conanfile.py (m4/1.4.19): Calling build() conanfile.py (m4/1.4.19): Calling:
"/c/users/marc/appdata/local/temp/tmp.lft3bbpsbo/m4/src/configure" --prefix=/ --bindir=${prefix}/bin --sbindir=${prefix}/bin --libdir=${prefix}/lib --includedir=${prefix}/includincludedir=${prefix}/include gl_cv_func_printf_directive_n=no gl_cv_func_snprintf_directive_n=no gl_cv_func_snprintf_directive_n=no ac_cv_func__set_invalid_parameter_handler=yes ERROR: conanfile.py (m4/1.4.19): Error in build() method, line 107 autotools.configure() ConanException: Cannot wrap command with different envs, ['C:\Users\marc\AppData\Local\Temp\tmp.LFt3bBpSBO\m4\build-release\conan\conanbuild.bat'] - ['C:\Users\marc\AppData\Local\Temp\tmp.LFt3bBpSBO\m4\build-release\conan\conanbuild.sh'] - []
Things appear to be working correctly without these conf settings (modulo the packaging issue identified in #12685) despite the fact that I am invoking conan-2.0 from within a Bash script running in a Git Bash window. I believe this is because this recipe (and others) are explicitly adding a tool_requires dependency on msys2 if the bash settings are not previously set. Is this intended to be a supported workflow?
Again, the only issue I am seeing during the build command is the one noted above with ORIGINAL_PATH, Perusing the MSYS2 source code on GitHub, it sounds like it may only be the "Git for Windows" instance of bash that is paying attention to this variable and causing problems. Quoting:
In Git for Windows' default mode, that ORIGINAL_PATH value is the used to define the PATH variable explicitly
Hi @memsharded, This issue bit me again today when I was debugging something and called "conan-2.0 build" directly rather than through my automation that now does an "unset ORIGINAL_PATH" to work around this issue. Thus I put in another plug for adding something similar into Conan proper so that other users do not encounter this subtle failure mode.
Environment details
Steps to reproduce
Logs
Here's the output with some debug instrumentation and slightly edited output:
conan-2.0 build -pr:b tools.jinja -pr:h tools.jinja --name m4 --version 1.4.19 . # --build=never final_command is ["C:\Users\marc\AppData\Local\Temp\tmp.IwEMme6231\m4\build-release\conan\conanbuild.bat" && "C:\Users\marc\AppData\Local\Temp\tmp.IwEMme6231\m4\build-release\conan\msys2_mode.bat" && C:\Users\marc.conan2\p\c2bbc405b72a9345\p\bin\msys64\usr\bin\bash.exe --login -c ^". \^"C:\Users\marc\AppData\Local\Temp\tmp.IwEMme6231\m4\build-release\conan\conanbuild.sh\^" ^&^& printenv ^&^& \^"/c/users/marc/appdata/local/temp/tmp.iwemme6231/m4/src/configure\^" --prefix=/ --bindir=${prefix}/bin --sbindir=${prefix}/bin --libdir=${prefix}/lib --includedir=${prefix}/include --oldincludedir=${prefix}/include gl_cv_func_printf_directive_n=no gl_cv_func_snprintf_directive_n=no gl_cv_func_snprintf_directive_n=no ac_cv_func__set_invalid_parameter_handler=yes ^"]
-------- Input profiles -------- Profile host: [settings] arch=x86_64 build_type=Release compiler=msvc compiler.cppstd=14 compiler.runtime=dynamic compiler.runtime_type=Release compiler.version=192 os=Windows [tool_requires] !openssl*: cmake/3.24.2
Profile build: [settings] arch=x86_64 build_type=Release compiler=msvc compiler.cppstd=14 compiler.runtime=dynamic compiler.runtime_type=Release compiler.version=192 os=Windows [tool_requires] !openssl*: cmake/3.24.2
-------- Computing dependency graph -------- Graph root conanfile.py (m4/1.4.19): C:\Users\marc\AppData\Local\Temp\tmp.IwEMme6231\m4\conanfile.py Build requirements cmake/3.24.2#de544be3bdac5a39bf43ef20ca86c9d8 - Cache msys2/cci.latest#c2c59de30b6dd4090dcc00c22859265e - Cache
-------- Computing necessary packages -------- Build requirements cmake/3.24.2#de544be3bdac5a39bf43ef20ca86c9d8:581183ca2ec1945c2d8e6bd2fb4795f24f993e62#83abd46d5d9b48cc99aff33793a56e72 - Cache msys2/cci.latest#c2c59de30b6dd4090dcc00c22859265e:ea3606590bcd730f9c5363293046107800d8da53#c5d09ac848e472f1f3aff5e4330cd3d0 - Cache
-------- Installing packages --------
-------- Installing (downloading, building) binaries... -------- cmake/3.24.2: Already installed! cmake/3.24.2: Appending PATH environment variable: C:\Users\marc.conan2\p\3183c3e6020bdf99\p\bin WARN: The use of 'env_info' is deprecated in Conan 2.0 and will be removed in Conan 2.X. Please, update your recipes unless you are maintaining compatibility with Conan 1.X msys2/cci.latest: Already installed! msys2/cci.latest: Creating MSYS_ROOT env var : C:\Users\marc.conan2\p\c2bbc405b72a9345\p\bin\msys64 msys2/cci.latest: Creating MSYS_BIN env var : C:\Users\marc.conan2\p\c2bbc405b72a9345\p\bin\msys64\usr\bin WARN: The use of 'env_info' is deprecated in Conan 2.0 and will be removed in Conan 2.X. Please, update your recipes unless you are maintaining compatibility with Conan 1.X WARN: The use of 'env_info' is deprecated in Conan 2.0 and will be removed in Conan 2.X. Please, update your recipes unless you are maintaining compatibility with Conan 1.X msys2/cci.latest: Appending PATH env var with : C:\Users\marc.conan2\p\c2bbc405b72a9345\p\bin\msys64\usr\bin WARN: The use of 'env_info' is deprecated in Conan 2.0 and will be removed in Conan 2.X. Please, update your recipes unless you are maintaining compatibility with Conan 1.X
-------- Finalizing install (deploy, generators) -------- conanfile.py (m4/1.4.19): Calling generate() conanfile.py (m4/1.4.19): Aggregating env generators conanfile.py (m4/1.4.19): Calling build() conanfile.py (m4/1.4.19): Calling:
ORIGINAL_PATH=/c/Program Files/Git/mingw64/bin:/c/Program Files/Git/usr/bin:...
configure: loading site script /etc/config.site checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... yes checking for a race-free mkdir -p... /c/users/marc/.conan2/p/c2bbc405b72a9345/p/bin/msys64/usr/bin/mkdir -p checking for gawk... gawk checking whether make sets $(MAKE)... yes checking whether make supports nested variables... yes checking whether make supports nested variables... (cached) yes checking for gcc... cl -nologo checking whether the C compiler works... no configure: error: in
/c/Users/marc/AppData/Local/Temp/tmp.IwEMme6231/m4/build-release': configure: error: C compiler cannot create executables See
config.log' for more details ERROR: conanfile.py (m4/1.4.19): Error in build() method, line 107 autotools.configure() ConanException: Error 77 while executing ERROR: Conan-2.0 build failed for 'm4' (conan-2.0)