conan: Conan fails to detect the compiler although `CC` and `CXX` are set
Environment details
- Operating System+version: ubuntu-22.04
- Compiler+version: 13.1.0
- Conan version: 2.0.9
- Python version: 3.11.4
Steps to reproduce
I am creating a Conda package of my software, as part of a Github C/I workflow. My software depends on other software (e.g.: Boost). For dependencies for which there isn’t a Conda package available I use Conan to install them.
Here is the idea, scattered over the various files (.github/workflows/linux-conda.yml
, environment/conda/build.sh
):
- Create a Conda environment
- Install the boa Conda package builder and execute:
conda mambabuild environment/conda --override-channels --channel conda-forge
Then build.sh
is executed which includes:
conan profile detect
conan install . \
--profile=default \
--settings:host compiler.cppstd=17 \
--settings:build compiler.cppstd=17 \
--settings:build build_type=Release \
--build=missing \
--output-folder=build
This results in an error (see log below). Conan is not able to correctly detect the compiler. The CC
and CXX
variables are set, so I would expect that those are used to detect the compiler.
I tried passing in the compiler explicitly, when calling conan install
, using --setting compiler=$CXX
, but that failed with ERROR: 'settings.compiler' value not defined
. Maybe because the whole compiler section is missing from the profile?
I think this is a bug, given that the compiler is installed and pointed to by the standard variables. If not, then my question is how to get Conan to detect the compiler correctly in this situation.
I use the same conan commands to install Conan packages outside of the Conda build environment (on Linux, macOS, Windows), and those work fine. It seems that the Conda build environment is confusing Conan. Maybe because of the atypical setting of CC
and CXX
?
Logs
2023-08-24T16:10:09.7983374Z CC and CXX: /usr/share/miniconda/envs/test/conda-bld/lue_1692893106258/_build_env/bin/x86_64-conda-linux-gnu-cc, /usr/share/miniconda/envs/test/conda-bld/lue_1692893106258/_build_env/bin/x86_64-conda-linux-gnu-c++
2023-08-24T16:10:09.7984827Z ERROR: Not able to automatically detect '/usr/share/miniconda/envs/test/conda-bld/lue_1692893106258/_build_env/bin/x86_64-conda-linux-gnu-cc' version
2023-08-24T16:10:09.7985898Z No compiler was detected (one may not be needed)
2023-08-24T16:10:09.7986712Z WARN: This profile is a guess of your environment, please check it.
2023-08-24T16:10:09.7987819Z WARN: The output of this command is not guaranteed to be stable and can change in future Conan versions.
2023-08-24T16:10:09.7988301Z WARN: Use your own profile files for stability.
2023-08-24T16:10:09.7988673Z Saving detected profile to /home/runner/.conan2/profiles/default
2023-08-24T16:10:09.8382941Z + conan install . --profile=default --settings:host compiler.cppstd=17 --settings:build compiler.cppstd=17 --settings:build build_type=Release --build=missing --output-folder=build
2023-08-24T16:10:10.1836158Z ERROR: 'settings.compiler' value not defined
Somewhat later on in the log:
2023-08-24T16:10:10.3898835Z Detected profile:
2023-08-24T16:10:10.3899230Z [settings]
2023-08-24T16:10:10.3899457Z arch=x86_64
2023-08-24T16:10:10.3899668Z build_type=Release
2023-08-24T16:10:10.3900101Z os=Linux
About this issue
- Original URL
- State: closed
- Created 10 months ago
- Reactions: 1
- Comments: 17 (9 by maintainers)
@memsharded I think the problem is this logic here:
In a conda environment, the CC and CXX variables point to
/opt/conda/envs/<env name>/bin/x86_64-conda-linux-gnu-cc
and/opt/conda/envs/<env name>/bin/x86_64-conda-linux-gnu-c++
andcommand
ends up being/opt/conda/envs/<env name>/bin/x86_64-conda-linux-gnu-cc
and thus_gcc_compiler(command)
is never called.A possible fix is:
I put up a PR as an example.
I will try to find out what is going on.