Package manager automatically overwrites manual changes

Hello, I recently submitted a PR for a fix to a package we are using in our project. However, until the pull request is merged (and a new release made), I made a fix manually to Library\PackageCache (normally .gitignored) and re-included the specific file in the .gitignore.

The issue is that it seems like the package manager is manually overwriting the change, and I’m not sure if it’s just automatically detecting the change and downloading the “correct” version? I don’t think it’s git related, but I wasn’t able to figure out what could cause this reading through the docs.

Thanks for any help,
Erik

You should not edit anything in the Library directory. The packages in the Library/PackageCache/ are considered read-only and it’s no surprise your changes can get overwritten.

What you want to do is to convert the external read-only package into a local read-write package. Then you can edit it and check it into version control.

There’s two main ways of doing that, either just copy the folder from Library/PackageCache/ into Packages/ or use the PackageManager.Client.Embed editor API to do it for you.

Any package inside the Packages/ folder will override the same package in the manifest and whatever version or source you set there will be ignored. To revert to the external package, simply remove the folder from the Packages/ directory.

3 Likes

Thanks very much for the help, really nice to see there is a supported way to do this kind of overriding, everything worked nicely :slight_smile: