HLL
HLL

Reputation: 415

Docker with cmake error: ForceToRelativePath failed

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.

Upvotes: 7

Views: 985

Answers (2)

Jonathan Chow
Jonathan Chow

Reputation: 1467

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

Upvotes: 2

HLL
HLL

Reputation: 415

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

Upvotes: 10

Related Questions