Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker with cmake error: ForceToRelativePath failed

Tags:

docker

cmake

I have been trying to compile a project in docker using cmake. However, I get the following error:

cmake: /build/cmake-pCygIN/cmake-3.13.4/Source/cmOutputConverter.cxx:125: static std::__cxx11::string cmOutputConverter::ForceToRelativePath(const string&, const string&): Assertion `local_path.empty() || local_path[local_path.size() - 1] != '/'' failed.

This is using the following Dockerfile, for a helloworld c script

WORKDIR .
COPY ./ ./
RUN apt-get update && apt-get -y install cmake
WORKDIR ./build
RUN  cmake ..  && make

The cmake command works fine in my home environment. I presume this is because I have not installed something in the docker environment, but I am not sure what it would be.

like image 429
HLL Avatar asked Dec 31 '22 23:12

HLL


2 Answers

If anyone else encounters this issue, the problem is running cmake in the root directory. Moving all the code into a ./src/ file, and changing the dockerfile to:

FROM python:3.7
WORKDIR .
COPY ./ ./
RUN apt-get update && apt-get -y install cmake
WORKDIR ./build
RUN  cmake ../src  && make

Fixes the issue

like image 185
HLL Avatar answered Jan 04 '23 02:01

HLL


As HLL suggested, running cmake in the root directory will cause that error, complete Dockerfile as follow:

WORKDIR .
COPY ./ ./src
RUN apt-get update && apt-get -y install cmake
RUN  cmake ../src  && make
like image 42
Jonathan Chow Avatar answered Jan 04 '23 04:01

Jonathan Chow