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] {{profile_dir}} is expanded incorrectly when used in subdir #15726

Closed
andrey-zherikov opened this issue Feb 21, 2024 · 9 comments · Fixed by #15727
Closed

[bug] {{profile_dir}} is expanded incorrectly when used in subdir #15726

andrey-zherikov opened this issue Feb 21, 2024 · 9 comments · Fixed by #15727
Assignees
Milestone

Comments

@andrey-zherikov
Copy link

Environment details

  • Operating System+version: Windows 11
  • Compiler+version: N/A
  • Conan version: 2.1.0
  • Python version: 3.10.2

Steps to reproduce

Small setup.bat file to create profiles:

set CONAN_HOME=%cd%\.conan2
mkdir %CONAN_HOME%\profiles\fragment\os
(echo [conf] & echo tools.cmake.cmaketoolchain:user_toolchain = [ "{{profile_dir}}/toolchain.cmake" ]) > %CONAN_HOME%\profiles\fragment\os\windows
echo include(fragment/os/windows) > %CONAN_HOME%\profiles\myprofile

Once executed, it creates the following structure in .conan2 dir:

├── profiles
│   ├── fragment
│   │   └── os
│   │       └── windows
│   └── myprofile

File content for reference:

  • profiles/myprofile
    include(fragment/os/windows)
    
  • profiles/fragment/os/windows
    [conf]
    tools.cmake.cmaketoolchain:user_toolchain = [ "{{profile_dir}}/toolchain.cmake" ]
    

Logs

Execute conan profile show -pr:a myprofile and see invalid toolchain path:

Host profile:
[settings]
[conf]
tools.cmake.cmaketoolchain:user_toolchain=['C:\\conan-test\\.conan2\\profiles\x0cragment/os/toolchain.cmake']

Build profile:
[settings]
[conf]
tools.cmake.cmaketoolchain:user_toolchain=['C:\\conan-test\\.conan2\\profiles\x0cragment/os/toolchain.cmake']
@memsharded
Copy link
Member

Thanks for your report @andrey-zherikov

This was an unfortunate issue with the loading of confs and Windows backslash.
I am submitting a fix in #15727 for next release.

@memsharded memsharded added this to the 2.2.0 milestone Feb 22, 2024
@memsharded
Copy link
Member

#15727 merged, this will be in the next release

@andrey-zherikov
Copy link
Author

@memsharded Is it possible to port this fix into 2.1.* patch release?
I think I'm facing this issue in our prod:
I have tools.cmake.cmaketoolchain:user_toolchain = [ "{{conan_home_folder}}/profiles/toolchain/{{platform.system().lower()}}.cmake" ] in global.conf
This is expanded to the following piece of profile:

[conf]
tools.cmake.cmaketoolchain:user_toolchain=['D:\\Jenkins\\workspaces\\conan\\workspace\ty_cmake-install-bb-library_main@2/.conan2/profiles/toolchain/windows.cmake']

And \t in the path above is converted to <tab>:

-- Using Conan toolchain: D:/Jenkins/workspaces/conan/workspace/ty_cmake-install-bb-library_main@2/.conan2/p/b/cmakef116027922a0c/b/conan_toolchain.cmake
CMake Error at D:/Jenkins/workspaces/conan/workspace/ty_cmake-install-bb-library_main@2/.conan2/p/b/cmakef116027922a0c/b/conan_toolchain.cmake:17 (include):
  include could not find requested file:

    D:/Jenkins/workspaces/conan/workspace	y_cmake-install-bb-library_main@2/.conan2/profiles/toolchain/windows.cmake
Call Stack (most recent call first):
C:/basbuild/build-tools/cmake/share/cmake-3.26/Modules/CMakeDetermineSystem.cmake:148 (include)
CMakeLists.txt:3 (project)

@memsharded
Copy link
Member

At the moment a patch release is not planned, those are reserved mostly for regressions or large impact bugs.
I'll sync with the team, the Conan 2.2 release shouldn't be far away.

@andrey-zherikov
Copy link
Author

@memsharded Is there any 2.2 pre-release I can test with?

@memsharded
Copy link
Member

Running from develop2 branch (clone and pip install -e . in the repo)

@andrey-zherikov
Copy link
Author

Tested with Conan version 2.2.0-dev - seems it's a different bug and it's still there:

-- Using Conan toolchain: C:/1/ty_cmake-install-bb-library_main@2/.conan2/p/b/cmake151f9b67b11af/b/conan_toolchain.cmake
CMake Error at C:/1/ty_cmake-install-bb-library_main@2/.conan2/p/b/cmake151f9b67b11af/b/conan_toolchain.cmake:17 (include):
  include could not find requested file:

    C:� y_cmake-install-bb-library_main@2/.conan2/profiles/toolchain/windows.cmake
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.23/Modules/CMakeDetermineSystem.cmake:124 (include)
  CMakeLists.txt:3 (project)

@memsharded Do you want me to create another issue?

@memsharded
Copy link
Member

Yes, please, open another ticket with details to reproduce that new error.
It might be a difficult one to reproduce, looks like path encodings issues.

@andrey-zherikov
Copy link
Author

Created #15868

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

Successfully merging a pull request may close this issue.

2 participants