Fatal: cannot use bare repository

Hi there, that's my first post.

There is an ongoing issue (at least I believe it to be ongoing) where some developers start to have issue fetching swift packages via SPM.

There is a opened thread on Apple Forum about it, and support recommended to post on Swift Forum.
https://forums.developer.apple.com/forums/thread/747070?answerId=810504022#810504022

It seems this issue is reproducible whether via XCode SPM window or via command line.

The temporary solution that some developers found and that I can confirm works is to remove the following from ~/.gitconfig

[safe]
    bareRepository = explicit

The above is a solution, but I think most developers will hit their head on a wall before figuring this out.

Thank you in advance for anyone able to help.

10 Likes

Thank you for posting this - I can confirm I'm also experiencing the same issue and the same workaround cleared it up for me.

Edited to add: Seems relevant that I had just updated SourceTree when this started happening.

1 Like

I upgraded SourceTree this morning and the problem started. The upgrade added:

[safe]
    bareRepository = explicit

to ~/.gitconfig. Removed it and Xcode worked again.

A bug has been filed with Atlassian. https://jira.atlassian.com/browse/SRCTREE-8176

6 Likes

Thanks eholley! I remember updating SourceTree last week or so. Actually, just before deleting it to use lazygit instead :smile:

I was getting started for the first time on SPM yesterday and didn't understand the errors I was getting when trying to consume the package I created. Spent a day hitting my head on a wall... Thank you @minoo555!!

I just had this issue too and it was SourceTree that added the bareRepository = explicit that made it not work (see the link to the Atlassian bug posted above)

just having this problem since this morning, checking this and solve the problem! thank you

Deleting this won't solve the problem - Sourcetree will add it next time you use it. You also need to go to Settings in Sourcetree and deselect "Allow Sourcetree to modify your global Mercurial and Git configuration files".