Unsafe repository errors when indexing or viewing a review in Fisheye/Crucible
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
Fisheye/Crucible is suddenly unable to run git commands due to a check at the git level. Reviews and indexing are impacted and the following can be seen in the UI and application logs:
com.atlassian.fisheye.dvcs.handler.DvcsProcessException: Error while communicating with VCS: fatal: unsafe repository ('$FISHEYE_INST/var/cache/local_repo/clone' is owned by someone else)
To add an exception for this directory, call:
git config --global --add safe.directory
Environment
- confirmed on Fisheye 4.8.9 and Linux but likely applies to all supported versions and platforms
Diagnosis
confirm the subdirs of FISHEYE_INST and FISHEYE_INSTALLATION are all owned by the same user running the Fisheye application
cd $FISHEYE_INST && find . ! -user <feuser>
Cause
If the user is not the same or a different user owns files and/or directories git might complain about an unsafe repo:
Even if the user running Fisheye is root on a Linux Distribution this issue can occur if there are files/dirs owned by another user.
Typically this is the result of Fisheye being first stood up using a dedicated user eg. feuser and then on subsequent start up a different user like root is used.
Solution
Ensure the same user running Fisheye/Crucible owns all the files and directories in Fisheye home and installation:
chown -R user:user $FISHEYE_INST
chown -R user:user $FISHEYE_INSTALLATION
chmod -R 755 $FISHEYE_INST
chmod -R 755 $FISHEYE_INSTALLATION
To round everything out we ensure sensible file permissions using chmod