Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We are updating our Terms of Service for all Unity subscription plans, effective October 13, 2022, to create a more streamlined, user-friendly set of terms. Please review them here: unity.com/legal/terms-of-service.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Custom Package with Git Dependencies

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

  1. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    740
    Now this is stale again. Are there any progress at all? Could you just make works about this feature be more transparent?
     
  2. dpeter99

    dpeter99

    Joined:
    Sep 29, 2013
    Posts:
    7
    This is the second quite big road block in 2 days. And as far as I can see now i have to set up an NPM server and probably pay for hosting just so my Untility package can be downloaded, when somebody uses the main package.
    I get that unity is focusing on bug fixes... but in my eye this is a big bug.
     
  3. D1234567890

    D1234567890

    Joined:
    Aug 11, 2019
    Posts:
    32
    GH and GL both have package registries so you can serve NPM packages from them. I have used GL for standalone packages in the manifest but not as dependencies yet.
     
  4. PerunCreative_JVasica

    PerunCreative_JVasica

    Joined:
    Aug 28, 2020
    Posts:
    47
  5. Vadimskyi

    Vadimskyi

    Joined:
    Jan 13, 2020
    Posts:
    12
    This issue is a big deal to package creators.
    I'm hesitating on using third-party dependency resolvers, since they rely on Unity's internal api which can change any moment.
     
  6. JeromeGodboutAmotus

    JeromeGodboutAmotus

    Joined:
    Apr 24, 2020
    Posts:
    40
    Why is this still a thing in 2021? a package manager that cannot resolve dependencies? can we git ssh key per domain too please? what a pain for such a basic features.
     
  7. noio

    noio

    Joined:
    Dec 17, 2013
    Posts:
    198
    +1

    The prospect of pulling out some commonly used utilities into packages seemed attractive! Just uploading each of them to a separate git repo and have the dependency of one utility on the other resolved automatically.

    For me that's the main use case..

    The only other simple solution is to just create one monolithic "utilities" package? Makes it a lot less attractive to go down the upm road. I guess I'll just keep copying files from one project to the next. :(
     
  8. starikcetin

    starikcetin

    Joined:
    Dec 7, 2017
    Posts:
    322
    Any news on this one?
     
  9. sandolkakos

    sandolkakos

    Joined:
    Jun 3, 2009
    Posts:
    225
    Since it looks like we are not gonna have UPM handling git dependencies, the better option at the moment is using Scoped Registries, where you would create NPM packages out of your Unity Package and upload it to a NPM service and add the registry URL to your list of Scoped Registries on the Unity Package Manager Settings.

    I did test some services and the better option for having a private Registry was JFrog in my opinion.

    I'm writing a document with my Pros and Cons when using them (Verdaccio, JFrog, Gitlab, AWS CodeArtifact, NPM). And when I finish it I will share it here.
     
    nilsdr likes this.
  10. starikcetin

    starikcetin

    Joined:
    Dec 7, 2017
    Posts:
    322
    There is still the problem of not being able to declare the scope of dependencies in the
    package.json
    itself.
     
  11. sandolkakos

    sandolkakos

    Joined:
    Jun 3, 2009
    Posts:
    225
    There is no problem at all when using Scoped Registries.
    You can declare all your dependencies in the package.json exactly how Unity does with their packages. If they are found in any registry added to your PackageManager settings (Unity registry is done automatically), all of them will be resolved automatically.

    That is how I do it:

    package.json
    Code (json):
    1. {
    2.   "name": "com.mycompanyname.mypackagename",
    3.   "version": "1.0.12",
    4.   "displayName": "My Package Name",
    5.   "description": "My package description",
    6.   "keywords": [
    7.     "mypackagename"
    8.   ],
    9.   "author": {
    10.     "name": "Packages with the same author are grouped on UPM window"
    11.   },
    12.   "dependencies": {
    13.     "com.unity.localization": "1.0.1",
    14.     "com.unity.addressables": "1.19.6",
    15.     "com.mycompanyname.myutilities": "1.0.7",
    16.     "com.othercompanyname.singleton": "1.0.1"
    17.   }
    18. }
    Packages/manifest.json
    Code (json):
    1. {
    2.   "scopedRegistries": [
    3.     {
    4.       "name": "My JFrog Registry",
    5.       "url": "https://mycompany.jfrog.io/artifactory/api/npm/unity-npm-local",
    6.       "scopes": [
    7.         "com.mycompanyname",
    8.         "com.othercompanyname"
    9.       ]
    10.     }
    11.   ]
    12. }
     
  12. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    368
    The problem is that if your scoped registry package depends on a second scoped registry, both scopes will have to be defined at the project level.

    Would love to be proven wrong.
     
  13. sandolkakos

    sandolkakos

    Joined:
    Jun 3, 2009
    Posts:
    225
    Are you talking about the
    "name": "@ scope/packagename"
    issue?
    If it is not about that specific issue (which I still don't fully understand), I believe it is correct to add every scoped registry since Unity needs to know from where it should download the dependencies.

    btw, I'm not an expert at NPM scoped registries, I have started looking into it this year just to make it work on Unity and it really works perfectly with JFrog for my needs.
     
  14. Michael-Ryan

    Michael-Ryan

    Joined:
    Apr 10, 2009
    Posts:
    184
    @sandolkakos Are you still working on your pros/cons document, and is JFrog still your preferred solution?

    I just started working on migrating some code to UPM packages stored in private GitHub repositories, and I would like to establish a private scoped registry that will serve packages from those private repositories.

    I have minimal experience working with NPM scoped registries and no experience setting them up. Any information you share would be greatly appreciated.
     
    sandolkakos likes this.
  15. Michael-Ryan

    Michael-Ryan

    Joined:
    Apr 10, 2009
    Posts:
    184
    I've read in a few posts that seem to suggest JFrog (like the GitHub Packages registry) doesn't allow searching the registry for available packages, but that it does resolve dependencies fine. Is that the case? It would be great to have the Unity Package Manager UI show all packages available on the private registry.
     
  16. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    790
    Can't speak for JFrog Artifactory but I've been running a Verdaccio instance and that has worked well. Package info, listing and searching works on the Unity side and it's relatively straightforward to install (I have it running in a docker container). I'm using Git hooks to automatically publish packages whenever I push a new tag.
    Verdaccio does seem to be geared more towards single-instance smaller setups and Artifactory more towards being part of a bigger infrastructure.
     
    Michael-Ryan likes this.
  17. sandolkakos

    sandolkakos

    Joined:
    Jun 3, 2009
    Posts:
    225
    @Michael-Ryan
    I was formatting the text and also trying to find a place to post it. So I used Gatsby + GitHub Pages.

    That is a compilation of my findings regarding the use of the Unity Package Manager + package dependencies:
    https://sandolkakos.github.io/my-blog/upm-studies/
     
    Last edited: Feb 5, 2022
  18. ekyah411

    ekyah411

    Joined:
    Aug 12, 2019
    Posts:
    6
    @sandolkakos thanks for the summary, it is very useful!
    I managed to get public npmjs packages to be visible in UPM though.
    For me, the problem was that one of the scope names was too long and it was not discoverable (e.g. com.supersuperlongname.name1.name2). After shortening this name it worked o_O
     
    sandolkakos likes this.
  19. sandolkakos

    sandolkakos

    Joined:
    Jun 3, 2009
    Posts:
    225
    Hey @ekyah411, nice to know that you like my post.

    Hmm, I haven't thought about long names. Could you try my packages with the settings you use:
    com.sandolkakosdigital.myunitypackage01
    com.sandolkakosdigital.myunitypackage02

    they are hosted here:
    https://www.npmjs.com/settings/sandolkakos/packages
     
  20. sandolkakos

    sandolkakos

    Joined:
    Jun 3, 2009
    Posts:
    225
    Wowww, I can confirm it.
    I just created another package with a shorter company name "com.sandolkakos.myunitypackage03" and it is now showing on the UPM window.
    Thanks for the hint @ekyah411, I will include it in my blog post.

     
    Molder and ekyah411 like this.
  21. Krahgnatokz

    Krahgnatokz

    Joined:
    Mar 18, 2014
    Posts:
    8
    Bump...?
    I'm trying to create incremental packages that I can reuse in my projects. Is there some easy and obvious solution that I'm missing instead of making a package for each piece of functionality?
     
  22. sandolkakos

    sandolkakos

    Joined:
    Jun 3, 2009
    Posts:
    225
    You can create packages with the structure you decide. But I strongly recommend following that layout:
    - https://docs.unity3d.com/Manual/cus-layout.html

    We have a lot of ways of creating/importing a Package using the Unity Package Manager, but maybe as a starting point for working with packages, you could do one of those (sorted by difficulty):

    1. Create a new folder inside your `UnityProject/Packages` with a package.json
    - you will see the folder inside your Unity Editor, as a child of the Packages folder.
    - do what you want inside it
    - commit it normally with your game code (same project and not shared)

    2. Create a git repository with a package.json at the root of the repo
    - clone it to a specific folder of your PC
    - import that folder using the Unity Package Manager > Add package from disk...
    - do what you want inside it
    - commit and push the content to your specific remote repo
    - In the project you just want to reuse:
    - import the git package using the Unity Package Manager > Add package from git URL...

    3. When you start to understand more about how the packages are handled, you will for sure want to learn how to use the Scoped Registries to store your packages.
     
  23. bartix96pl

    bartix96pl

    Joined:
    May 31, 2019
    Posts:
    6
    How about your ETA? Permission granted to get this feature in Unity 2022 ;)
     
  24. joshrs926

    joshrs926

    Joined:
    Jan 31, 2021
    Posts:
    49
    Any news on resolving git dependencies per package? I’d love to be able to write packages of code for my projects that depend on each other and then install one and the package manager automatically install the other packages from github that the installed package depends on.
     
  25. sandolkakos

    sandolkakos

    Joined:
    Jun 3, 2009
    Posts:
    225
    It is totally possible. For that you need to store your packages in an NPM service and make use of the Unity Scoped Registries to add the URL where your packages are stored, so that the Unity Package Manager will be able to download them and resolve dependencies as well.

    I wrote a blog text about how I have learned thst and maybe it can give you an idea about how it works:
     
  26. starikcetin

    starikcetin

    Joined:
    Dec 7, 2017
    Posts:
    322
    They are Git URLs, which means he doesn't have a registry, and he is using Git URLs instead. Not a registry, but Git URLs. I repeat: Git repos as Git URLs, not an NPM-like registry.

    Unity doesn't have native support for this, and currently, the only way to make it work is by using something like this: https://github.com/mob-sakai/GitDependencyResolverForUnity

    I don't know why you are doing it, but please stop dodging the issue.
     
    Thaina and ImpossibleRobert like this.
  27. sandolkakos

    sandolkakos

    Joined:
    Jun 3, 2009
    Posts:
    225
    ohhh, totally my bad. I was reading that on my cell phone and totally missed the "git" word in joshrs926 question. Okay, git dependencies are not possible, sorry for my misleading.

    I'm just sharing a knowledge that I didn't have before and was bringing so much pain to my brain every time I wanted to keep on the same track with git URLs.

    Should I wait for Unity to redesign their whole UPM system (if they would do that someday) or should I try anything else to have a good workflow in my projects?
    Well, if I have the Scoped Registries to help me with what I need, I will of course make use of it instead of trying to use half of the functionalities I would have by using git URLs.

    I believe there are more people in the same situation I was in before, so talking about it really helps those guys. But if one does not want it, that is fine. There are lots of people that would like to develop games in Unity using Python as the programming language, but since Unity uses C#, what can those guys do about it?
     
  28. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    740
    Not in this thread because this thread from start to now only related to
    Custom Package with Git Dependencies
     
  29. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    790
    My point from more than two years ago still stands – don't plan on this feature arriving soon, find a good workflow with what's available now. As @sandolkakos has outlined.
     
  30. szsahajsz

    szsahajsz

    Joined:
    Aug 17, 2018
    Posts:
    13
    we still hope, this + custom dependency for specific samples within the package.
     
unityunity