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] Calling unix_path from package_info fails when consumer is instantiating dependencies #12785

Closed
System-Arch opened this issue Dec 24, 2022 · 4 comments
Assignees

Comments

@System-Arch
Copy link
Contributor

Environment details

Steps to reproduce

conan-2.0 test -pr:b tools.jinja -pr:h tools.jinja test_package autoconf/2.71

Logs

conan-2.0 test -pr:b tools.jinja -pr:h tools.jinja test_package autoconf/2.71

-------- 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

-------- test_package: Computing dependency graph --------
Graph root
autoconf/2.71 (test package): C:\Users\marc\AppData\Local\Temp\tmp.kyGSJHhY5N\autoconf\test_package\conanfile.py
Build requirements
autoconf/2.71#2579fa898aac6f0469db54b650f4fbf2 - Cache
cmake/3.24.2#de544be3bdac5a39bf43ef20ca86c9d8 - Cache
m4/1.4.19#c0a288506117bce50ec77bd9a83c07a0 - Cache
msys2/cci.latest#c2c59de30b6dd4090dcc00c22859265e - Cache

-------- test_package: Computing necessary packages --------

-------- Computing necessary packages --------
Build requirements
autoconf/2.71#2579fa898aac6f0469db54b650f4fbf2:da39a3ee5e6b4b0d3255bfef95601890afd80709#94f42e1b5c0d4a13e9045f07be3a11a3 - Cache
cmake/3.24.2#de544be3bdac5a39bf43ef20ca86c9d8:581183ca2ec1945c2d8e6bd2fb4795f24f993e62#83abd46d5d9b48cc99aff33793a56e72 - Cache
m4/1.4.19#c0a288506117bce50ec77bd9a83c07a0:723257509aee8a72faf021920c2874abc738e029#47e74be80f13e45933ce001a35966e97 - Skip
msys2/cci.latest#c2c59de30b6dd4090dcc00c22859265e:ea3606590bcd730f9c5363293046107800d8da53#c5d09ac848e472f1f3aff5e4330cd3d0 - Cache

-------- test_package: 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
m4/1.4.19: Already installed!
m4/1.4.19: Appending PATH environment variable: C:\Users\marc.conan2\p\12a1d8318ac8ea9d\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
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
autoconf/2.71: Already installed!
ERROR: autoconf/2.71: Error in package_info() method, line 107
dataroot_path = unix_path(self, os.path.join(self.package_folder, "res", "autoconf"))
ConanException: win_bash=True but tools.microsoft.bash:subsystem configuration not defined
ERROR: Conan-2.0 test failed for 'autoconf'

@System-Arch
Copy link
Contributor Author

System-Arch commented Dec 24, 2022

Hi @memsharded,
As I was doing additional testing with the fix for #12685, I discovered a similar looking issue that is probably the same as or closely related to #12499. Strangely, the above log clearly shows that msys2 is installed and that its package_info method is called as evidenced by the setting of MSYS_ROOT and MSYS_BIN. It is the same method that sets tools.microsoft.bash:subsystem to "msys2" using:

    self.conf_info.define("tools.microsoft.bash:subsystem", "msys2")

so it is a mystery as to why the autoconf package_info method is erroring out.

Note also that I have opened PR conan-io/conan-center-index#14925 with the version of the autoconf recipe that I used to reproduce this issue. Unfortunately, it fails to run there with either Conan 1.x or Conan 2.0 because CCI is running with older versions of Conan that lack the needed fixes to exhibit this downstream issue. Thanks

@memsharded
Copy link
Member

Hi @System-Arch

Sorry about the delay, I wrote some response for this and probably didn't submit it, and I lost it.

I think the main idea is that package_info() should never call unix_path(). As package_info() is information for the consumers, and unix_path() is conditioned to a running subsystem, like msys2, typically for building and packaging, but not for the consumer, it doesn't make sense to convert some path to that subsystem, because the consumers might and will probably not run in that subsystem.

Furthermore, it is very possible, that different consumers will consume that package in different scenarios, needing the path formatted in different ways. For example one consumer might run in msys2 (typical autotools project), needing the path in one way and another consumer will run in the native Windows cmd (typical CMake build), needing the path in another way.

So it is the responsibility of the consumers to format the path in the way they need it, not a responsibility of the recipes.
Conan generators like VirtualRunEnv and VirtualBuildEnv already manage this automatically, converting paths in the consumer side, so it is not necessary to do anything in the recipe.

Please let me know if this clarifies it.

@System-Arch
Copy link
Contributor Author

Hi @memsharded,

Thanks for the insights. The use of unix_path() in this context predated my efforts to get things working with Conan 2.0 so I had assumed that they were proper and necessary; however, following your recommendation and simply removing them seems to eliminate the failures with no observable negative consequences. I did have to make some other tweaks to get autoconf and automake to build and run their test_packages but was ultimately able to get them to both work. Thanks again for your help.

@System-Arch
Copy link
Contributor Author

Addressed via #12886 for those situations where the use of unix_path in package_info could not be eliminated entirely for Conan 1.x support (for example, see conan-io/conan-center-index#16248)

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

2 participants