Update command failed

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?


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

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

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.

This is the output:

   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:


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

and see the following output:

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

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?).

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…

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:


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.

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

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