[BUG] Cannot export if using version control to manage releases
SorraTheOrc opened this issue · 6 comments
Describe the bug
My release process involves a release/stable
branch maintained in Git. In order to create a release I checkout this branch into a separate location and have package-tools export the source into this directory. But this throws the error below. This error is because it is trying to delete the .git directory - which is not desired.
System.UnauthorizedAccessException: Access to the path "F:\Unity Projects\WizardsCode\DevLogger-Release\.git\objects\pack\pack-cd2674ec3c25d4b3d28b5a9fc15b955db020c6bd.idx" is denied.
at System.IO.File.Delete (System.String path) [0x00073] in <9577ac7a62ef43179789031239ba8798>:0
at System.IO.Directory.RecursiveDelete (System.String path) [0x0003f] in <9577ac7a62ef43179789031239ba8798>:0
at System.IO.Directory.RecursiveDelete (System.String path) [0x00024] in <9577ac7a62ef43179789031239ba8798>:0
at System.IO.Directory.RecursiveDelete (System.String path) [0x00024] in <9577ac7a62ef43179789031239ba8798>:0
at System.IO.Directory.Delete (System.String path, System.Boolean recursive) [0x00009] in <9577ac7a62ef43179789031239ba8798>:0
at System.IO.DirectoryInfo.Delete (System.Boolean recursive) [0x00000] in <9577ac7a62ef43179789031239ba8798>:0
at (wrapper remoting-invoke-with-check) System.IO.DirectoryInfo.Delete(bool)
at JCMG.PackageTools.Editor.FileTools.RecursivelyDeleteDirectoryContents (System.IO.DirectoryInfo directoryInfo) [0x00030] in F:\Unity Projects\WizardsCode\DevLogger\Library\PackageCache\com.jeffcampbellmakesgames.packagetools@7bd34d8b47\PackageTools\Scripts\Editor\Tools\FileTools.cs:242
at JCMG.PackageTools.Editor.FileTools.CreateOrUpdatePackageSource (JCMG.PackageTools.Editor.PackageManifestConfig packageManifest) [0x000ed] in F:\Unity Projects\WizardsCode\DevLogger\Library\PackageCache\com.jeffcampbellmakesgames.packagetools@7bd34d8b47\PackageTools\Scripts\Editor\Tools\FileTools.cs:96
UnityEngine.Debug:LogErrorFormat(Object, String, Object[])
JCMG.PackageTools.Editor.FileTools:CreateOrUpdatePackageSource(PackageManifestConfig) (at Library/PackageCache/com.jeffcampbellmakesgames.packagetools@7bd34d8b47/PackageTools/Scripts/Editor/Tools/FileTools.cs:161)
JCMG.PackageTools.Editor.PackageManifestConfigInspector:OnInspectorGUI() (at Library/PackageCache/com.jeffcampbellmakesgames.packagetools@7bd34d8b47/PackageTools/Scripts/Editor/Inspectors/PackageManifestConfigInspector.cs:189)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
Unity Version:
Unity 2019.4.15f1
To Reproduce
I have an open source project which makes it easy to reproduce step by step instructions at
https://github.com/TheWizardsCode/DevLogger#release-process
Expected behavior
The DevLogger-Release
folder contains the correct package and I can git add .
, git commit -m "release v 0.2.5"
, git push
Additional context
I think I can probably work around this by force pushing to the repo. I will test this out and post a workaround if it works. However, it may be simpler if .git files were not deleted. What do you think?
Should I work on a patch?
Workaround:
- Delete the existing package directory
- Export the package source
- cd into the package directory
git init
git remote add origin git@...
git fetch
git add .
git commit -m "Release v0.2.5
git branch -m master release/stable
git push -f -u origin release/stable
Is your .git
folder hidden? I also use this tool to export to a separate orphan branch on a different clone of the same repository, but have not seen this issue. One reason I think it may be this is that the delete process ignores hidden folders for exactly this kind of scenario.
[EDIT: this comment is not relevant, see next comment]
A little more info on this. The .git folder was a red herring. It is also happening in a devtest publication folder in which I am not version controlled. Here the error is System.IO.IOException: F:\Unity Projects\WizardsCode\Character-DevTest\package.json already exists at System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) [0x0012c] in <9577ac7a62ef43179789031239ba8798>:0
Looks like .git
just happened to be the first file it tried to delete.
Are you using Windows Subsystem for Linux? I'm wondering if this is some kind of wierd permissions problem based on that (I am using it, so knowing if you are using it or not will help in debugging).
I'm on a deadline right now, but I'll try to debug this soon. The workaround of manually deleting is OK for now.
The second issue is unrelated. This happens if you put the package manifest descriptor in the directory containing the project being packaged, moving them back to the Asset folder root fixed it.
The first problem, with .git folder still exists, I've not had time to debug yet, I'm still using the above workaround
In a new project this issue is not occurring. I believe it may be an oddity with that specific project and windows file locks