Native Git fails when system TMP or TEMP directories contain spaces in the path

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Symptoms

Bamboo build fails to fetch branch and the following appears in the Bamboo build logs:

1 2 3 4 5 Build working directory is d:\bamboo\builds\BAM-BAMBOO-JOB1 01-Nov-2012 12:31:14 Executing build BAM-BAMBOO-JOB1-32 01-Nov-2012 12:31:14 Starting task 'Checkout Default Repository' of type 'com.atlassian.bamboo.plugins.vcs:task.vcs.checkout' 01-Nov-2012 12:31:14 Updating source code to revision: 776a51ab4ad1874267dc4d0371fd10990c0fcf6d 01-Nov-2012 12:31:14 Cannot fetch branch '(unresolved) 776a51ab4ad1874267dc4d0371fd10990c0fcf6d' from 'git@github.com:path/Bamboo.git' to source directory 'd:\bamboo\builds\BAM-BAMBOO-JOB1'. command 'C:\Program Files (x86)\Git\bin\git.exe' ls-remote ssh://3456ba5b-f440-4ae5-b2a2-bd19a1d51685@127.0.0.1:1356/company/Bamboo.git failed with code 128. Working directory was [d:\bamboo\builds\BAM-BAMBOO-JOB1]., stderr:['C:\Documents' is not recognized as an internal or external command,, operable program or batch file., fatal: The remote end hung up unexpectedly]

Cause

There are spaces in the system TMP/TEMP directory paths. This issue is being tracked here: https://jira.atlassian.com/browse/BAM-12375

Resolution

This is a generic Git + Windows limitation. What happens is that Bamboo creates an SSH wrapper script in the current temporary directory and configures Git to use it via GIT_SSH variable. We need to use the wrapper to pass additional parameters to SSH.

This solution works fine, unless the platform is Windows and the temp directory name contains a space character. It's a bug in Git code used on Windows platform. We've fixed it and submitted a patch to Git developers.

The easiest solution is to change the temp directory. For instance, running the remote agent (or Bamboo server - depending where the job runs) with "java.io.tmpdir" set to a directory without spaces in the name helps to work around the issue.

Updated on April 8, 2025

Still need help?

The Atlassian Community is here for you.