question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

conan.cmake fails when using pyenv

See original GitHub issue

Issue

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:open
  • Created 3 years ago
  • Reactions:2
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
czoidocommented, Feb 22, 2021

Hi @BlueSolei, Thanks a lot for reporting and proposing the fix, we’ll try to reproduce and fix the issue.

1reaction
maldagcommented, Jan 18, 2022

I opened this issue, but after using Conan for a while, I understood that the right way to go about here is to use python’s virtual environment. This way you don’t care about pyenv, as inside the virtual environment you have python.exe which works great 😃

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:

pyenv local 3.x.y
pyenv shell python -m venv. env # force creation of virtualenv with given pyenv version 3.x.y
.env\scripts\activate
# now in virtualenv
pip install -U conan
conan install ... # whatever
Read more comments on GitHub >

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

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found