如何在 docker 中安装 conan 并使用

问题描述

我试图通过将 Conan 安装在 Docker 中并使用该 Docker 来使用它。同样,我确实喜欢 在 Dockerfile 中包含这些行

RUN apt-get install -y python3-pip
RUN sudo python3 -m pip install conan

在启动 docker 容器后,我的 CMakeFile.txt 中有这些行

conan_cmake_run(
    REQUIRES
    ${CONAN_PACKAGES})

构建我的项目需要 ${CONAN_PACKAGES}。运行 cmakefile 时出现此错误

-- Conan: Automatic detection of conan settings from cmake
-- Conan: Settings= -s;build_type=Debug;-s;compiler=gcc;-s;compiler.version=8;-s;compiler.libcxx=libstdc++11
-- Conan: checking conan executable
-- Conan: Found program /usr/bin/conan
-- Conan: Version found 
-- Conan executing: /usr/bin/conan install . -s build_type=Debug -s compiler=gcc -s compiler.version=8 -s compiler.libcxx=libstdc++11 -g=cmake
CMake Error at cmake/conan.cmake:402 (message):
  Conan install Failed='No such file or directory'
Call Stack (most recent call first):
  cmake/conan.cmake:497 (conan_cmake_install)
  CMakeLists.txt:17 (conan_cmake_run)


-- Configuring incomplete,errors occurred!

添加 conan_remote 工作正常。 但是在创建 docker 容器后,在 docker 中执行这些行修复了问题

pip install conan
sudo ln -s ~/.local/bin/conan /usr/bin/conan

以我对conan的初步了解,我意识到它是在寻找用户级安装。但是在 docker 中,一切都以 root 身份安装。 有人可以帮忙解决这个问题吗? 我正在使用这个版本的柯南:https://github.com/conan-io/cmake-conan/tree/release/0.15

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)