"A directory to use as a work tree for <PROJECT_KEY>/<REPO_SLUG> could not be created" is reported due to insufficient disk space
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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
Summary
The message "A directory to use as a work tree for <PROJECT_KEY>/<REPO_SLUG> could not be created
" is shown while performing the following actions through the Bitbucket UI:
Merging a pull request
The merge cannot be completed and will display the message in the "Merge pull request" dialog box:
Editing files through the in-browser editor and committing changes
Changes made through the built-in browser editor are not committed.
A popup error message will show up:
The same message is then displayed in the "Commit file" dialog:
Cause
For both cases, the actions cannot be completed because there is not enough space in the Bitbucket Home directory to create a new work directory for performing background operations.
Diagnosis
Bitbucket application logs will show warnings that there is not enough space in the file system.
Samples would be log entries indicating caching has been temporarily disabled due to insufficient space.
2021-01-20 12:30:00,044 WARN [git-hook-callback:thread-13] user *9XYZISx835x1790145x0 10.94.196.14 "POST /scm/PROJECT1/repo1.git/git-upload-pack HTTP/1.1" c.a.util.contentcache.ContentCache 1265: Caching has been temporarily disabled because there is not enough free space on /var/atlassian/application-data/bitbucket/caches/scm/123 (34480000 bytes free)
Solution
Ensure that there is sufficient disk space in the Bitbucket Home directory.