Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Custom Package with Git Dependencies

Discussion in 'Package Manager' started by OloinMilsom, Feb 12, 2019.

  1. OloinMilsom

    OloinMilsom

    Joined:
    Jan 21, 2019
    Posts:
    2
    Using Unity 2018.3.1f1 I am investigating if it's possible to create a dependency in a custom package's package.json to another custom package.

    For example, I created two package.json files like these:

    Dependency

    Code (JavaScript):
    1. {
    2.     "name": "com.test.dependency",
    3.     "displayName": "Test Dependency",
    4.     "version": "0.0.1",
    5.     "unity": "2018.3",
    6.     "description": "bla bla bla",
    7.     "category": "Unity",
    8.     "dependencies": {}
    9. }
    Depender
    Code (JavaScript):
    1. {
    2.     "name": "com.test.depender",
    3.     "displayName": "Test Depender",
    4.     "version": "0.0.1",
    5.     "unity": "2018.3",
    6.     "description": "bla bla bla",
    7.     "category": "Unity",
    8.     "dependencies": {
    9.         "com.test.dependency": "https://github.com/GitUserName/Test.Dependency.git"
    10.     }
    11. }

    I then created a new unity project and added the Depender to the manifest.json:
    Code (JavaScript):
    1. {
    2.     "dependencies": {
    3.         "com.test.depender": "https://github.com/GitUserName/Test.Depender.git",
    4.         ...
    5.     }
    6. }
    Upon opening this project I get the following error:
    Package com.test.depender@https://github.com/GitUserName/Test.Depender.git has invalid dependencies:
    com.test.dependency: Version 'https://github.com/GitUserName/Test.Dependency.git' is invalid. Expected a 'SemVer' compatible value.

    I'm wondering if there's anything I've missed that would get this working. If it is not possible, as the errors would suggest, to have custom dependencies in a package.json file, will this be supported in future?
     
    Last edited: Feb 12, 2019
  2. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    203
    For security and stability reasons, this is currently not supported, by design. I can't say whether or not this feature will be supported in the future for custom packages, but I expect that no published package hosted by Unity will ever be allowed this since it essentially side-steps any kind of validation/verification of the package.

    What you can do, however, is use a scoped registry (a.k.a. private registry) to publish your custom packages on a registry you control. (See https://forum.unity.com/threads/setup-for-scoped-registries-private-registries.573934/ for more information on how to set this up.)

    Also note that while the packages are embedded in your project or declared as a dependency in your project manifest, they override any package of the same name found as a package dependency during dependency resolution. So, barring the use of a scoped registry, your above setup would work if you explicitly added the Dependency package in your project manifest using a Git URL, and updated your Depender package.json so it did not declare a dependency on the Dependency package or declared it with a version (that would be ignored in favor of the project dependency on Dependency).
     
    OloinMilsom likes this.
  3. Karnsteiner

    Karnsteiner

    Joined:
    Mar 24, 2013
    Posts:
    25
    I might be mistaken, but it seems like Oloin is referring more to a package hosted on his own git repository versus one hosted by Unity. I am also looking at this for splitting up an open source project hosted on github into several smaller packages with one core and the others as optional secondaries requiring core.

    It seems implied that something like this might work based on what forum threads/documentation I've found, but now requires a user to list all dependencies of a package independently in the manifest.json file and won't account for sub-dependencies (two levels deep dependencies or more).

    Package.json
    Code (JavaScript):
    1. {
    2.     "name": "com.test.depender",
    3.     "displayName": "Test Depender",
    4.     "version": "0.0.1",
    5.     "unity": "2018.3",
    6.     "description": "bla bla bla",
    7.     "category": "Unity",
    8.     "dependencies": {
    9.         "com.test.dependency": "1.0.0"
    10.     }
    11. }
    Manifest.Json
    Code (JavaScript):
    1. {
    2.     "dependencies": {
    3.         "com.test.dependency": "https://github.com/GitUserName/Test.Dependency.git",
    4.         "com.test.depender": "https://github.com/GitUserName/Test.Depender.git",
    5.         ...
    6.     }
    7. }
     
    k0dep and Stephen-Hodgson like this.
  4. k0dep

    k0dep

    Joined:
    Jul 21, 2013
    Posts:
    5
  5. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    438
    This is seriously annoyingly nonsense. The usable of package manager is to let us able to share any package with any dependency package and the manager will resolve all dependency automatically. If you don't let us upload all of our package on your server directly then it limit the usability of the manager. We must uselessly include all of our sub package in our own package or else we cannot share it

    If we only develop individually or internally then we don't really need package manager at all. The point is to share the package as a submodule to anyone and anywhere. Scope registry is totally useless and waste of time on your side. We only need git dependency and custom dependency. I really want to ask who was think about this idea and waste all your time? Have you even think about the use case scenario before add this feature?

    We just need a custom dependency. Not a useless workaround like scoped registry unless the scope registry could be resolved from dependency. If we tell people that "you can add our package into package manager" but then "oh but you also need to add this line in this file and these lines in this file and this line in these files" then it become totally pointless to have package manager
     
  6. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    203
    Hi @Thaina,

    I'm sorry to hear that the Package Manager does not exactly fit your requirements.

    We are still working on putting the required infrastructure, tooling, and publishing flows to enable external contributions to the Package Manager registry. That is why I mentioned setting up a private registry would be the first step in sharing custom packages.

    Setting up your own registry (for instance Verdaccio -
    https://github.com/verdaccio/verdaccio) is actually pretty simple. It's installed using npm, and run using a single command-line. Configuring the Package Manager to use that scoped registry is also not too complicated - an action you need to do once per project so the Package Manager knows where to look in addition to the main registry (see https://docs.unity3d.com/Manual/upm-scoped.html) when it resolves the project's dependencies.

    For example, you could add the following to a project manifest:
    Code (CSharp):
    1. "scopedRegistries": [
    2.     {
    3.       "name": "My Registy",
    4.       "url": "<http(s)-url-to-your-registry>",
    5.       "scopes": [
    6.         "com.thaina"
    7.       ]
    8.     }
    9. ],
    10.  
    and all packages whose name begins with
    com.thaina.
    would be fetched from that registry, which you're free to administer as you wish.
     
  7. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    438
    @maximeb_unity That's the point that I would call it pointless

    The point is, this feature is Package Manager. It was named as "Package Manager" and you can see that every popular package manager, be it NPM or NuGet, has an ability to resolve all of it dependency as first priority. Because if the package can resolve dependency in one machine but failed to resolved in another machine without tweaking configuration, That package would become useless, and also the manager itself would be a totally useless manager

    And to config each and every machine just to use one package is defeating the purpose of using package manager itself. So if any feature want to have be named Package Manager it should have a way to resolve dependency of any depth from the package itself without having people go manage each dependency when they just want to include another package

    People try to include package in their project for their convenience. But you are making this useless package manager that force people to do inconvenience things it defeat the purpose of using Package Manager immediately

    an action I need to do once per project is not acceptable for the feature named Package Manager. It must be an action I need to do once per package. It must be an action that, when I tell some people to include my package. They only really need to just include my package and done, the manager will do everything on its own to resolve every bits of dependency into that person's project, any number of person and any number of project, to have each person need to tweak each project they create just to use my package it a uselessly annoyingly inconvenience loss cost

    Because the usability of the feature named Package Manager is that, I am not the one who use it. There would be many people to use it by installing my package into their project

    This is why I want to ask that, have you ever think about the use case scenario of this feature? Have you ever think about the actual use case scenario of feature named Package Manager ? Who have suggest you to try doing that useless scope registry feature before custom dependency? You trying to present scope registry is telling me that you are all half heartedly in designing the feature named Package Manager. You don't understand the use case of Package Manager at all. Unless the scope registry can be resolved from the package. Which I have trying and it was not

    If you making feature named Package Manager you then must have thought about this. If not you should just name it Unity Registry Package Installer UI not a Package Manager or else it will become a false advertisement
     
    Last edited: May 6, 2019
  8. insominx

    insominx

    Joined:
    Jan 23, 2012
    Posts:
    27
    This seems to be limited to Github due to Topic. Is there a way to make this work elsewhere like off of gitlab?
     
    k0dep likes this.
  9. k0dep

    k0dep

    Joined:
    Jul 21, 2013
    Posts:
    5
    Yes, indeed, the current implementation has limitations associated with GitHub. Now I am working on the development of the whole ecosystem for working with packages regardless of their location, I plan to finish by the end of the month.
     
  10. Rock360

    Rock360

    Joined:
    Oct 26, 2016
    Posts:
    8
    Hi.
    I found an awesome repo and thought it should be shared.
    This plugin looks like a PERFECT solution for me!
    https://github.com/mob-sakai/GitDependencyResolverForUnity

    (From the README)

    This plugin resolves git url dependencies in the package for Unity Package Manager.
    You can use a git url as a package dependency!

    Features
    • Easy to use: just install
    • Resolve git url dependencies in packages
    • Uninstall unused packages that is installed by this plugin
    • Support GitHub, Bitbucket, GitLab, etc.
    • Support private repository
    • Support Unity 2019.1+
    • Support .Net 3.5 & 4.x
    • Update package with a specific tag/branch
    Install
    • Find Packages/manifest.json in your project and edit it to look like this:
    Code (JavaScript):
    1. {
    2.   "dependencies": {
    3.     "com.coffee.git-dependency-resolver": "https://github.com/mob-sakai/GitDependencyResolverForUnity.git#1.0.0",
    4.     ...
    5.   }
    6. }
    • To update the package, change #{version} to the target version. Or, use UpmGitExtension.
     
  11. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    438
  12. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    203
    Hi @Thaina,

    Git-based dependencies in packages are on the roadmap for 2020. I don't have a specific ETA however.
     
    quabug, FabioMAG and Thaina like this.
  13. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    438
    Thank you. But still, could it be possible for opensourcing it, so we could contribute or just using it as is?
     
  14. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    203
    I'm not sure what the plans regarding open sourcing it. At this time it's not possible but I will pass the suggestion along. Thank you for your continued interest!
     
    Thaina likes this.
  15. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    263
    can a custom package in scoped registry depend on another package that is in an other scoped registry? We have ar tools in our own registry which depend on the vuforia package, which is in their own scoped registry.

    Can I somehow define in the package manifest that the vuforia package is to come from another scoped registry, or would I have to define vuforias registry in the importing projects manifest?
     
  16. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    438
    Unity 2020 is already beta. Where is git dependency support?
     
  17. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    512
    Unity 2020.1 is beta. Maxime only said it's on the roadmap for 2020, not if it'll land in 2020.1, 2020.2 or 2020.3 (or at all – being on the roadmap is no guarantee).

    I wouldn't hold my breath waiting for it and look for alternatives in the meantime.
     
  18. Davidtr_Unity

    Davidtr_Unity

    Unity Technologies

    Joined:
    Mar 5, 2020
    Posts:
    10
    Hi @nilsdr,

    Yes, this is supported. You would need to configure both scoped registries at the project level.



    Hi @Thaina,

    Git dependency support didn't make 2020.1 but it is still on the roadmap.
     
    Thaina likes this.
  19. Jerry-Lee

    Jerry-Lee

    Joined:
    Apr 10, 2014
    Posts:
    2
    Last edited: May 28, 2020
    JamsCenter likes this.
  20. Saucyminator

    Saucyminator

    Joined:
    Nov 23, 2015
    Posts:
    38
    This issue I was having took a while to find. Please add this info in the Known issues thread.
     
  21. ImpossibleRobert

    ImpossibleRobert

    Joined:
    Oct 10, 2013
    Posts:
    331
    I want to add that this is really unfortunate and it seems like a very annoying design decision not to allow or actually even to prohibit this, as it works already in package manager. Why not let the users decide?
     
  22. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    438
    Now is 2020.2 alpha. Why it still not support?
     
  23. UnityMaru

    UnityMaru

    Community Engagement Manager Unity Technologies

    Joined:
    Mar 16, 2016
    Posts:
    644
    Hey there. This is something that is still on our radar but we haven't got any form of ETA to provide as to when this will be supported.
     
  24. aut0mata

    aut0mata

    Joined:
    Aug 22, 2014
    Posts:
    4
    Trying to use GitLab private repos for Packages dependencies (both SSH/HTTPS) and I`m not able to install them through UPM, not even with the cited extension...

    Any ETA on fix?
     
  25. UnityMaru

    UnityMaru

    Community Engagement Manager Unity Technologies

    Joined:
    Mar 16, 2016
    Posts:
    644
    It sounds like you're having issues with using private credentials to access a secure repo. It might be worth referring to the troubleshooting page for ssh and https when using git Urls. https://docs.unity3d.com/Manual/upm-errors.html#ssh-add
     
  26. Shaunyowns

    Shaunyowns

    Unity Technologies

    Joined:
    Nov 4, 2019
    Posts:
    274
    Got a bit more of an update from the PackMan team:

    "Unfortunately this is probably a ways off in terms of priorities. We are currently working on high priority items so new features like this have taken a back seat. Also, you may have heard the announcement that future versions of Unity will have dedicated themes and unless your work pertains to one of these themes, it will be harder to get new changes into the editor. For the foreseeable future, we may be working on bug fixes and stability, sorry!"
     
unityunity