conan.cmake fails when using pyenv
See original GitHub issueIssue
Hi,
The conan.cmake script fails due to the conan
command is not an executable.
I use PyEnv on windows, so my conan
command is a .bat file, or if running in Git-Bash, its a sh script.
The error I get is Conan install failed='%1 is not a valid Win32 application
Here is the cmake run:
√ /c/dev/expr/conan-training/requires_conditional (shaul) $ cmake -B build -S src/
-- Building for: Visual Studio 16 2019
-- The CXX compiler identification is MSVC 19.27.29110.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Conan: Using cmake-multi generator
-- Conan: Automatic detection of conan settings from cmake
-- Conan: Detected VS runtime: MD
-- Conan: Settings= -s;arch=x86_64;-s;build_type=Release;-s;compiler=Visual Studio;-s;compiler.version=16;-s;compiler.runtime=MD
-- Conan: checking conan executable
-- Conan: Found program C:/Users/sfridman/.pyenv/pyenv-win/shims/conan
-- Conan: Version found
-- Conan executing: C:/Users/sfridman/.pyenv/pyenv-win/shims/conan install . -s arch=x86_64 -s build_type=Release -s compiler=Visual Studio -s compiler.version=16 -s compiler.runtime=MD -g=cmake_multi
CMake Error at C:/dev/expr/cmake-conan/conan.cmake:455 (message):
Conan install failed='%1 is not a valid Win32 application'
Call Stack (most recent call first):
C:/dev/expr/cmake-conan/conan.cmake:540 (conan_cmake_install)
CMakeLists.txt:5 (conan_cmake_run)
-- Configuring incomplete, errors occurred!
See also "C:/dev/expr/conan-training/requires_conditional/build/CMakeFiles/CMakeOutput.log".
A fix
I manage to fix the issue by running the calls to conan
in a shell, like this:
set(SHELL_CONAN_CMD "cmd.exe")
set(SHELL_CONAN_ARGS "/C;${CONAN_CMD};${conan_args}")
string (REPLACE ";" " " _conan_args "${SHELL_CONAN_ARGS}")
message(STATUS "Conan executing: ${SHELL_CONAN_CMD} ${_conan_args}")
if(ARGUMENTS_OUTPUT_QUIET)
execute_process(COMMAND ${SHELL_CONAN_CMD} ${SHELL_CONAN_ARGS}
RESULT_VARIABLE return_code
OUTPUT_VARIABLE conan_output
ERROR_VARIABLE conan_output
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
else()
execute_process(COMMAND ${SHELL_CONAN_CMD} ${SHELL_CONAN_ARGS}
RESULT_VARIABLE return_code
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
I am quite a novice in CMake, so I don’t know what will be the right way to fix this.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:13 (5 by maintainers)
Top Results From Across the Web
conan.cmake fails with "Conan --version failed='2'" : CPP-29056
You get an error inside the conan.cmake code: "Conan --version failed='2'" ... I tried using a different CMake istead of the bundled one....
Read more >pyenv-win - Bountysource
Current implementation of shims as .bat files breaks some existing use cases. E.g. CMake wrapper for conan contains the following code fragment to...
Read more >homebrew-core - Homebrew Formulae
a2ps 4.14 Any‑to‑PostScript filter
aacgain 1.8 AAC‑supporting version of mp3gain
aalib 1.4rc5 Portable ASCII art graphics library
aamath 0.3 Renders mathematical expressions as ASCII art
Read more >how to fix configure: error: C compiler cannot create executables
any help would be great as the compiler fails on anytime I try to use it, not just with this install. config.log output:...
Read more >Installation troubleshooting — ROS 2 Documentation: Humble ...
pyenv seems to default to building Python with .a files, but that causes ... If you run into the CMake error file INSTALL...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @BlueSolei, Thanks a lot for reporting and proposing the fix, we’ll try to reproduce and fix the issue.
This is not always correct since you can create a virtualenv with activated pyenv-shell. That way you can also guarantee which python version will be used for virtualenv. Virtualenv just isolates python packages, not python versions.
So using this snippet will also cause problems: