# CMake test suite failing on Alpine Linux

**URL:** https://discourse.cmake.org/t/cmake-test-suite-failing-on-alpine-linux/5064
**Category:** Development
**Tags:** os:linux
**Created:** [February 19, 2022, 8:36am UTC](https://discourse.cmake.org/t/cmake-test-suite-failing-on-alpine-linux/5064 "2022-02-19T08:36:21Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![mayeut](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mayeut/32/2196_2.png) [@mayeut](https://discourse.cmake.org/u/mayeut)
#### Post date: [February 19, 2022, 8:36am UTC](https://discourse.cmake.org/t/cmake-test-suite-failing-on-alpine-linux/5064/1 "2022-02-19T08:36:21Z")

</div>

There are 3 tests failing in the CMake test suite when building from sources on Alpine Linux.  
I tried to crawl the CMake bug tracker & Google search to check if something was reported but did not find anything thus asking help here to check if I’m doing something wrong or if a bug shall be opened.

The minimal repro I have for this is:

```auto
docker run -it --rm alpine:3.15
apk add binutils gcc g++ gfortran curl util-linux ca-certificates gnupg openssl-dev cmake make musl-dev
apk add bzip2-dev curl-dev expat-dev libarchive-dev linux-headers libuv-dev ncurses-dev rhash-dev xz-dev zlib-dev py3-sphinx file musl-utils
curl -fsSLO https://github.com/Kitware/CMake/releases/download/v3.22.2/cmake-3.22.2.tar.gz
tar -xf cmake-3.22.2.tar.gz
cmake -S cmake-3.22.2 -B cmake-build -DCMAKE_USE_OPENSSL:BOOL=ON -DBUILD_TESTING:BOOL=ON
cd cmake-build
make -j4
./bin/ctest --output-on-failure -j4

```

Summary:

```auto
The following tests FAILED:
	 62 - ExportImport (Failed)
	532 - RunCMake.install (Failed)
	533 - RunCMake.file-GET_RUNTIME_DEPENDENCIES (Failed)

```

Error log extract:

```auto
CMake Error at /root/cmake-3.22.2/Tests/RunCMake/RunCMake.cmake:201 (message):
  TARGETS-RUNTIME_DEPENDENCIES-nodep-all - FAILED:

  Result is [1], not [0].

  stderr does not match that expected.

  Command was:

   command> "/root/cmake-build/bin/cmake" "-DCMAKE_INSTALL_PREFIX=/root/cmake-build/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCIES-nodep-build/root-all" "-DBUILD_TYPE=Debug" "-P" "cmake_install.cmake"

  Actual stdout:

   actual-out> -- Install configuration: "Debug"
   actual-out> -- Installing: /root/cmake-build/Tests/RunCMake/install/TARGETS-RUNTIME_DEPENDENCIES-nodep-build/root-all/bin/exe

  Expected stderr to match:

   expect-err> ^$

  Actual stderr:

   actual-err> CMake Error at cmake_install.cmake:62 (file):
   actual-err> file Failed to run ldconfig

Call Stack (most recent call first):
  /root/cmake-3.22.2/Tests/RunCMake/RunCMake.cmake:215 (run_cmake)
  /root/cmake-3.22.2/Tests/RunCMake/install/RunCMakeTest.cmake:15 (run_cmake_command)
  /root/cmake-3.22.2/Tests/RunCMake/install/RunCMakeTest.cmake:183 (run_install_test)

```

All errors seem to have to do with `file Failed to run ldconfig`.

On a side note, it seems the test suite is never run on Alpine Linux official package:

- added 2017-09-20: alpinelinux/aports/commit/09e4dd994fe45731bb5d2d11a333e2d17c9d8a05
- removed/skipped 2017-09-22: alpinelinux/aports/commit/6e01dd13be82b9a24218d9983f59e3aed35556e9

Related to investigation of [https://gitlab.kitware.com/cmake/cmake/-/issues/23187](https://gitlab.kitware.com/cmake/cmake/-/issues/23187) / [https://github.com/scikit-build/cmake-python-distributions/issues/221](https://github.com/scikit-build/cmake-python-distributions/issues/221)

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [February 20, 2022, 2:15pm UTC](https://discourse.cmake.org/t/cmake-test-suite-failing-on-alpine-linux/5064/2 "2022-02-20T14:15:42Z")

</div>

It seems that `musl`-based platforms are not all that well-considered in the `file(GET_RUNTIME_DEPENDENCIES)` code. How should CMake discover the default library paths in such cases?

Cc: @kyle.edwards

---

<div class="post-metadata">

### Author: ![awilfox](https://discourse.cmake.org/user_avatar/discourse.cmake.org/awilfox/32/2216_2.png) [@awilfox](https://discourse.cmake.org/u/awilfox)
#### Post date: [February 23, 2022, 8:00am UTC](https://discourse.cmake.org/t/cmake-test-suite-failing-on-alpine-linux/5064/3 "2022-02-23T08:00:03Z")

</div>

I don’t think this is necessarily musl-specific but more Alpine-specific. We haven’t been having issues passing the test suite on Adélie Linux, which is also using musl. However, we use a [vastly different ldconfig](https://cgit.adelielinux.org/packages/tree/system/musl/ldconfig?h=1.0-RC2) to Alpine.

Ninja edit: from a trybuild on a big-endian IBM Power node with CMake 3.22.2: `553/583 Test #517: RunCMake.file-GET_RUNTIME_DEPENDENCIES ............ Passed 11.23 sec`

---

<div class="post-metadata">

### Author: ![vmsh0](https://discourse.cmake.org/user_avatar/discourse.cmake.org/vmsh0/32/2943_2.png) [@vmsh0](https://discourse.cmake.org/u/vmsh0)
#### Post date: [November 23, 2022, 10:46am UTC](https://discourse.cmake.org/t/cmake-test-suite-failing-on-alpine-linux/5064/4 "2022-11-23T10:46:06Z")

</div>

Hi,  
I’m also seeing this while building srecord-1.65.0 (which is CMake-based) on latest Alpine Linux.

During `cmake --install .`:

```auto
CMake Error at srec_cat/cmake_install.cmake:66 (file):
  file Failed to run ldconfig
Call Stack (most recent call first):
  cmake_install.cmake:52 (include)

```

I can’t attach the `srec_cat/cmake_install.cmake` file because I’m a new user, but the relevant part is:

```auto
if(CMAKE_INSTALL_COMPONENT STREQUAL "srec_cat" OR NOT CMAKE_INSTALL_COMPONENT)
  file(GET_RUNTIME_DEPENDENCIES
    RESOLVED_DEPENDENCIES_VAR _CMAKE_DEPS
    EXECUTABLES
      "/srecord-1.65.0-Source/build/srec_cat/srec_cat"
      "/srecord-1.65.0-Source/build/srec_cmp/srec_cmp"
      "/srecord-1.65.0-Source/build/srec_info/srec_info"
    DIRECTORIES
      "/usr/bin/"
    PRE_EXCLUDE_REGEXES
      "api-ms-"
      "ext-ms-"
    POST_EXCLUDE_REGEXES
      ".*system32/.*\\.dll"
    )
endif()

```

CMake version is 3.24.3.

This is currently breaking install of this package for me. Is there a workaround available?

Some additional info: `strace`ing `cmake --install .` I found out that it calls `ldconfig` as:

```auto
[pid 6642] execve("/sbin/ldconfig", ["/sbin/ldconfig", "-v", "-N", "-X"], 0x7ffd180a39d8 /* 7 vars */ <unfinished ...>
...
[pid 6642] +++ exited with 1 +++

```

So I’m guessing Alpine’s `ldconfig` does not cope well with those flags.
