# Update command failed

**URL:** https://discourse.cmake.org/t/update-command-failed/434
**Category:** Usage
**Created:** [December 23, 2019, 11:14pm UTC](https://discourse.cmake.org/t/update-command-failed/434 "2019-12-23T23:14:36Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![David\_Dixon](https://discourse.cmake.org/user_avatar/discourse.cmake.org/david_dixon/32/127_2.png) [@David\_Dixon](https://discourse.cmake.org/u/David_Dixon)
#### Post date: [December 23, 2019, 11:14pm UTC](https://discourse.cmake.org/t/update-command-failed/434/1 "2019-12-23T23:14:36Z")

</div>

Does anyone know how to debug update command failures? When I run my ctest script by hand, the update step succeeds. When run through CI it fails.

Update command failed: “git” “fetch”

Where can I find information regarding the cause of the failure?

Thanks!

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [December 24, 2019, 12:46pm UTC](https://discourse.cmake.org/t/update-command-failed/434/2 "2019-12-24T12:46:13Z")

</div>

Does `ctest -VV` provide enough detail to see what you need?

---

<div class="post-metadata">

### Author: ![David\_Dixon](https://discourse.cmake.org/user_avatar/discourse.cmake.org/david_dixon/32/127_2.png) [@David\_Dixon](https://discourse.cmake.org/u/David_Dixon)
#### Post date: [December 24, 2019, 4:19pm UTC](https://discourse.cmake.org/t/update-command-failed/434/3 "2019-12-24T16:19:33Z")

</div>

Unfortunately no - it shows some low-level variables that are set but I don’t get any output from git fetch…

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [December 28, 2019, 5:34am UTC](https://discourse.cmake.org/t/update-command-failed/434/4 "2019-12-28T05:34:38Z")

</div>

Have a look in the `Testing/Temporary` directory for a file called `LastUpdate*`. See if that contains any more information about why git fetch failed. You probably want to just capture all files in that directory as part of the CI job so you can have a look at all the files in that directory when the job finishes. Actually, maybe just capture the whole `Testing` directory and be done with it.

You can add your own git command line options to the update step to make the `git fetch` command more verbose. Try adding `--verbose` to the `CTEST_GIT_UPDATE_OPTIONS` variable before you `include(CTest)` in your project to see if that tells you more.

---

<div class="post-metadata">

### Author: ![David\_Dixon](https://discourse.cmake.org/user_avatar/discourse.cmake.org/david_dixon/32/127_2.png) [@David\_Dixon](https://discourse.cmake.org/u/David_Dixon)
#### Post date: [January 10, 2020, 11:01pm UTC](https://discourse.cmake.org/t/update-command-failed/434/5 "2020-01-10T23:01:56Z")

</div>

> [@craig.scott](#):
>
> `--verbose` to the `CTEST_GIT_UPDATE_OPTIONS`

This is the output:

```auto
SetCTestConfigurationFromCMakeVariable:UpdateCommand:CTEST_UPDATE_COMMAND
SetCTestConfiguration:UpdateCommand:git
SetCTestConfigurationFromCMakeVariable:GITUpdateOptions:CTEST_GIT_UPDATE_OPTIONS
SetCTestConfiguration:GITUpdateOptions:--verbose
   Use GIT repository type
   Old revision of repository is: c52c03184f7c2a9c4348d1807b63d671b349bc7c
   New revision of repository is: c52c03184f7c2a9c4348d1807b63d671b349bc7c
   Gathering version information (one . per revision):
    
   Update command failed: "git" "fetch" "--verbose"

```

Still no difference. I am doing a debug trace in the CI log too and that doesn’t give anything helpful…

Can you help me understand what “Gathering version information (one . per revision):” is doing. As you can see the revision is the same. I wonder if that is causing the failure. That is, running `git fetch` is succeeding but doing nothing so ctest considers that a failure…

I did the following:

```auto
ctest_update(SOURCE ${CTEST_SOURCE_DIRECTORY} CAPTURE_CMAKE_ERROR error_output RETURN_VALUE return_value)`

message("Update command return value: ${return_value}")
message("Update command error_output: ${error_output}")

```

and see the following output:

```auto
Update command return value: -1
Update command error_output: 0

```

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [January 11, 2020, 8:41am UTC](https://discourse.cmake.org/t/update-command-failed/434/6 "2020-01-11T08:41:31Z")

</div>

Based on that output, I really can’t see why the command is failing. As far as I can tell, all the code paths that would lead to failure should have recorded details in the log that I don’t see in the output that you posted (is that output from the `ctest` command or from the contents of the `LastUpdate.log` file though?).

---

<div class="post-metadata">

### Author: ![David\_Dixon](https://discourse.cmake.org/user_avatar/discourse.cmake.org/david_dixon/32/127_2.png) [@David\_Dixon](https://discourse.cmake.org/u/David_Dixon)
#### Post date: [January 22, 2020, 5:59pm UTC](https://discourse.cmake.org/t/update-command-failed/434/7 "2020-01-22T17:59:09Z")

</div>

I am convinced that if one calls ctest\_update and there is nothing to update that the command fails. I don’t know if this is the intended behavior but I suspect that git fetch or git pull resulting in “already up-to-date” will result in an update step failure. Some context: when using gitlab merge\_request trigger, gitlab will checkout the MR at the most recent revision. This happens before the ctest script is invoked, so when the update step is reached there is nothing to do - the repo is already up-to-date (which is a zero error code, but still results in an update step failure). That said, the only way to report a revision number to the dashboard is to call the update step…

---

<div class="post-metadata">

### Author: ![craig.scott](https://discourse.cmake.org/user_avatar/discourse.cmake.org/craig.scott/32/20_2.png) [@craig.scott](https://discourse.cmake.org/u/craig.scott)
#### Post date: [January 26, 2020, 9:04am UTC](https://discourse.cmake.org/t/update-command-failed/434/8 "2020-01-26T09:04:55Z")

</div>

In that case, you might want to set `CTEST_UPDATE_VERSION_ONLY` in your ctest dashboard script. We use this to report the git commit to CDash in our builds without the `ctest_update()` step actually trying to update anything. From the [`ctest(1)` manual](https://cmake.org/cmake/help/latest/manual/ctest.1.html#ctest-update-step):

> `UpdateVersionOnly`
> 
> Specify that you want the version control update command to only discover the current version that is checked out, and not to update to a different version.
> 
> - [CTest Script](https://cmake.org/cmake/help/latest/manual/ctest.1.html#ctest-script) variable: [`CTEST_UPDATE_VERSION_ONLY`](https://cmake.org/cmake/help/latest/variable/CTEST_UPDATE_VERSION_ONLY.html#variable:CTEST_UPDATE_VERSION_ONLY)

That doesn’t excuse the behavior you’ve observed, but it should be a suitable workaround for your use case.

---

<div class="post-metadata">

### Author: ![David\_Dixon](https://discourse.cmake.org/user_avatar/discourse.cmake.org/david_dixon/32/127_2.png) [@David\_Dixon](https://discourse.cmake.org/u/David_Dixon)
#### Post date: [January 26, 2020, 4:56pm UTC](https://discourse.cmake.org/t/update-command-failed/434/9 "2020-01-26T16:56:05Z")

</div>

Thanks so much! This is a much cleaner solution than what I was doing (supplying a no-op as the update command…).
