Search Unity

Custom package dependencies

Discussion in 'Package Manager' started by one_one, Jun 28, 2019.

  1. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    483
    Hi,

    this topic has popped up in a few places, but I couldn't find a central/definite answer, so I thought I'd open a thread. A common use-case of package managers is to manage custom packages. This should also include dependency handling - keeping track of and moving dependency packages manually is a major headache. This includes having custom packages as a dependency for other custom packages. The last info I can find is that there's internal discussions on whether that should even be a thing.
    Have I missed something or is there currently no way to do that with UPM? I still feel like this is such a common scenario that I must miss a straightforward way of doing it.
    Dependencies don't seem to be supported neither as local packages ('file:...') nor as git packages. Having all packages 'embedded' defeats the point: That would also require manual moving when dealing with multiple projects - or writing custom batch/symlink voodoo in addition to UPM. The only option I'm not sure about is scoped registries (hosted locally?) - could that work?
     
    Last edited: Jun 28, 2019
    Ragoo likes this.
  2. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    574
    one_one likes this.
  3. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    483
    Hi @okcompute_unity / Pascal,
    thanks for the reply! Glad to hear that is being worked on - and I hope I didn't sound too harsh in the first post. Do you have any rough ETA for that?
     
  4. okcompute_unity

    okcompute_unity

    Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    574
    You did not sound harsh at all :) As for the ETA, 2019.3 feature is locked and we are moving on to 2020.x development. So this will (hopefully) be available in 2020.x release cycle.

    Regards,

    Pascal
     
    one_one likes this.
  5. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    483
    Because 2020.x is still a while to go, I decided to go for locally hosted scoped registries with verdaccio. Which seems to work... okay-ish (except that packages will need to be re-'publish'ed whenever they're changed.)

    One issue I've run into is that I'm not sure how pre-compiled dependencies are supposed to work. If I add them as dependencies into the project, it works fine. But if they're dependencies of dependencies of a local package, it seems to break down / I can't use the code.
    To give an example, let's consider these three exemplary packages:
    • BusinessLogic (depends on package Serialization, dependency specified in package.json)
    • Serialization (depends on package Protobuf, dependency specified in package.json)
    • Protobuf (precompiled, only consists of a package.json and a .dll + meta files)
    Serialization cannot reference Protobuf if I only add BusinessLogic as a project dependency => throwing compiler errors. However, if I add Protobuf as a project dependency as well, it works.
    It seems like something about the auto referencing of assemblies is off here - but I have no idea. How can I check that? And is there a way to tell which packages have been loaded (implicitly) as dependencies of dependencies?
     
  6. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    483
    Here's another question: Is there a way to get the package manager to re-fetch a package again from the 'remote' server? Particularly if it's a package dependency, not a project dependency.
     
  7. M_R

    M_R

    Joined:
    Apr 15, 2015
    Posts:
    459
    1. close Unity
    2. delete the caches:
      • <project>/Library/PackageCache/<package>/
      • [in OSX] ~/Library/Unity/cache/packages/<registry>/<package>/ (windows has its own path)
    3. reopen Unity
     
    one_one likes this.
  8. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    483
    Thanks! The important part was to actually delete the packaged/tarball versions of the file as well as the unpackaged version. And the library.


    However, we changed our approach (and ditched verdaccio) thanks to this very recently released Git dependency resolver. I extended it last night to also work with local packages/directory junctions. If someone is interested, I'll look into doing a pull request.
     
  9. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    483
    Unfortunately, UPM is a filthy liar. It claims that
    Failed to resolve packages: [E:\GameDev\Core\Projects\UiPipelineSample\Packages] directory does not exist. No packages loaded
    . Which of course isn't true. There are, however, embedded packages in that folder (via directory junctions).
    Perhaps that has upset it? Even though I have the feeling it might be doing it out of spite and jealousy because I'm circumventing it in my attempts to get local package dependencies to work. If so, it is quite successful in destroying my plans and ruining my evening :<
    Either way, I would be extremely grateful for pointers here. (@okcompute_unity ? Or someone else from the team? Pretty please?)
     
  10. one_one

    one_one

    Joined:
    May 20, 2013
    Posts:
    483
    Okay, the issue seems to be that there are directory junctions in the Packages folder which seem to be corrupted and cannot be deleted. That seems to be tripping the package manager up, though the error message of 'packages directory does not exist' is not exactly on point if that's the case. Not sure if that's a known issue?