Search Unity

Package manager automatically overwrites manual changes

Discussion in 'Package Manager' started by Iron-Warrior, Jan 10, 2020.

  1. Iron-Warrior

    Iron-Warrior

    Joined:
    Nov 3, 2009
    Posts:
    838
    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
     
  2. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    1,066
    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. Iron-Warrior

    Iron-Warrior

    Joined:
    Nov 3, 2009
    Posts:
    838
    Thanks very much for the help, really nice to see there is a supported way to do this kind of overriding, everything worked nicely :)