Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unity cant add git packages on external SSD. FATAL: not in a git directory

I have an eSSD(external-SSD) where I store most of my unity projects because I have to access them on my desktop and latop for school. When ever I try to add a package using a git url I get the Cannot perform upm operation: Unable to add package [package]: Error when executing git command. fatal: not in a git directory error. This message also occurs when I add it manually to the manifest.json.

I do have git initialized an working because I am also storing my projects on git for version control which still works perfectly fine. For testing I cloned my project on one of my system drives and there upm had no problem installing the package. After which I recloned my project on my eSSD to make sure there was nothing corrupted, this also did not fix the problem.

I have stored my projects on an eSSD for years and never had any issues, so I opend up one of my older projects on my eSSD to check if they were still loading correcly, this was the case. So I switched from unity 2021.3.3f1 to 2019.4.39f1(which was the old project's version) to check if it was an version related issue. This was also not the case.

I also tried these solutions:

  • Unity forum post about simmilar issue.
  • Blog post about 'not a git directory'

So I don't know what is causing the issue at this point.

like image 796
MathiasBevers Avatar asked Oct 16 '25 16:10

MathiasBevers


1 Answers

I've been having the same issue drive me crazy for weeks now. On my end, the issue was a combination of

  • the external ssd being an exfat filesystem, rather than ntfs
  • git for windows new folder permissions change
  • the upm code not throwing errors when initializing the local package folder

Git will throw an error if you aren't the owner of a local repo folder you're trying to work with. But exfat doesn't support security permissions, so you can't even set yourself as the owner. The solution for me was to globally disable safe directories for git. I just added

[safe]
    directory = *

directly to my .gitconfig at %userprofile%/.gitconfig, but you can also run the command git config --global --add safe.directory "*" from cmd, or whatever terminal you're using.

Note that this totally disables the safety check, which is not ideal as far as I'm concerned. But for some reason trying to apply it just to the ssd drive or folder in the drive did not give me the desired results.

As for what Unity's doing, best I can tell, when the package manager pulls a package from git, it first initializes a temporary local repo in your project folder, and then tries to add core.longpaths to the .gitconfig if you're running windows. But the repo initialization is given the -q flag, so git doesn't return an error to the package manager. And so the package manager doesn't throw an error until it tries to run the config from the non-existent temporary folder in the project directory, giving us our fatal: not in a git director error message.

like image 67
0reo Avatar answered Oct 18 '25 12:10

0reo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!