# COMMAND\_ERROR\_IS\_FATAL output isn't particularly helpful

**URL:** https://discourse.cmake.org/t/command-error-is-fatal-output-isnt-particularly-helpful/7751
**Category:** Usage
**Created:** [March 22, 2023, 8:10pm UTC](https://discourse.cmake.org/t/command-error-is-fatal-output-isnt-particularly-helpful/7751 "2023-03-22T20:10:01Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Barry\_Revzin](https://discourse.cmake.org/user_avatar/discourse.cmake.org/barry_revzin/32/1283_2.png) [@Barry\_Revzin](https://discourse.cmake.org/u/Barry_Revzin)
#### Post date: [March 22, 2023, 8:10pm UTC](https://discourse.cmake.org/t/command-error-is-fatal-output-isnt-particularly-helpful/7751/1 "2023-03-22T20:10:01Z")

</div>

Consider this script:

```cmake
execute_process(
    COMMAND bash -c "exit 127"
    COMMAND_ERROR_IS_FATAL ANY
    )
message(STATUS "Got here")

```

This fails with:

```auto
$ cmake -P err.cmake
CMake Error at err.cmake:1 (execute_process):
  execute_process failed command indexes:

    1: "Child return code: 127"

```

Which is good - configuration does fail. However, the error isn’t very useful - it doesn’t actually say which command was running that failed, which can be very valuable in diagnosing the problem. It’d be great if `COMMAND_ERROR_IS_FATAL` caused cmake to log every (for `ANY)` or the one (for `LAST`) command that failed.

Compare that to this version:

```cmake
function(execute_process2)
    cmake_parse_arguments(ARGS "" "COMMAND_ERROR_IS_FATAL" "COMMAND" ${ARGV})
    execute_process(
        COMMAND ${ARGS_COMMAND}
        RESULT_VARIABLE result)
    if(result)
        message(FATAL_ERROR "command ${ARGS_COMMAND} failed with error: ${result}")
    endif()
endfunction()

execute_process2(
    COMMAND bash -c "exit 127"
    COMMAND_ERROR_IS_FATAL ANY
    )
message(STATUS "Got here")

```

which fails with:

```auto
CMake Error at err.cmake:7 (message):
  command bash;-c;exit 127 failed with error: 127
Call Stack (most recent call first):
  err.cmake:11 (execute_process2)

```

This still isn’t great, since it prints `bash;-c;exit 127` rather than `bash -c "exit 127"` and I have idea how to make that better, but at least I get an indication of what exactly failed.

---

<div class="post-metadata">

### Author: ![benthevining](https://discourse.cmake.org/user_avatar/discourse.cmake.org/benthevining/32/1924_2.png) [@benthevining](https://discourse.cmake.org/u/benthevining)
#### Post date: [March 22, 2023, 9:00pm UTC](https://discourse.cmake.org/t/command-error-is-fatal-output-isnt-particularly-helpful/7751/2 "2023-03-22T21:00:33Z")

</div>

+1! I definitely agree that CMake’s output for failed `execute_process` calls needs to be better.

---

<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: [April 3, 2023, 11:22am UTC](https://discourse.cmake.org/t/command-error-is-fatal-output-isnt-particularly-helpful/7751/3 "2023-04-03T11:22:07Z")

</div>

This seems worthy of [a feature request](https://gitlab.kitware.com/cmake/cmake/-/issues) to me.
