Search Unity

Git support on Package Manager

Discussion in 'Package Manager' started by rz_0lento, Oct 24, 2018.

  1. spaceemotion

    spaceemotion

    Joined:
    Sep 29, 2015
    Posts:
    95
  2. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,166
    That was discussed in another thread. You should raise your voice there too

    https://forum.unity.com/threads/custom-package-with-git-dependencies.628390/
     
    Last edited: Jan 6, 2020
    MaggerFabio likes this.
  3. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,643
    ok so without using external plugins, is not possible to use git url as dependencies inside a package.
     
  4. starikcetin

    starikcetin

    Joined:
    Dec 7, 2017
    Posts:
    340
    sebas77 likes this.
  5. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,643
    OK Currently I chose to use OpenUPM as solution.
     
  6. Deleted User

    Deleted User

    Guest

    I would really like to define a non-root git package (specifically to publish a Unity project git repo, with the package containing only the Asset directory).

    I saw this mentioned earlier in the thread but didn't find a follow-up.
    I thought GitHub packages could be a workaround for this, but couldn't get Unity to play nice with them.

    I feel like this is a really strong use case for existing code / new code that should include examples (my use case).
    Is support for this planned any time soon?
     
  7. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    826
    You can use the git subtree split command, like described here: https://www.patreon.com/posts/25070968

    I decided for the sake of simplicity to not include the complete project, but just the relevant folder in the git repo. This of course means, that you need to create a project on your own before including the package, but also makes it really easy to include the repo as a submodule, cuts right to the case and does not have any unity version changes and so on. If you need an example setup for that, take a look at https://github.com/supyrb/signals
     
  8. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    556
    We're currently working on adding support for packages stored in a sub-directory of the Git repository, opening up the possibility to use Git-based dependencies with repos tracking multiple packages. This is not available yet, but should be available in 2020.1.
     
    quabug, hschulte, nirvanajie and 5 others like this.
  9. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,166
    @maximeb_unity Will it use git feature like sparse checkout?

    Or unity need to invent new approach?
     
  10. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    556
    Sparse checkout is basically an optimization, and it's been around for a long time now, so this might be used as part of the feature, if possible and relevant. (Then again, sparse checkout does more than that and is useful for more complex flows than merely checking out.)
     
    Last edited: Jan 14, 2020
    Thaina likes this.
  11. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,166
    Actually I would like to make a request that, git package in manifest and dependency should be pulled with the git system. And, importantly, upm should unlock the pulled package folder so we could edit and commit package with the git command

    So if the UPM would developed to be more align with git system (such as, just using sparse checkout with the included package), it would be more likely that my request will be more possible to do

    What I hope is, when we include any package into our project with git, we could also edit and develop that package in the same time as developing the project, instead of having project for develop package separated from the actual project, and we could also commit the package with just git and don't need to switch back and forth between local and git in the manifest. We could just use git in package local folder and still share project for other people in the team
     
  12. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    556
    I understand that what you are looking for is a (legitimately!) better workflow and tools for developing a package, and a simpler way of switching back and forth between "development mode" and regular consumption. This is definitely something that we're looking into - but as you might know by now I don't have an ETA I can share for that yet.

    Even though such a feature would presumably use Git (and perhaps even other VCS backends), the current Git-based feature will not be changed as it serves a different purpose and use case than the one you describe. That is, while the current Git-based dependency feature uses a remote Git repository as the source of a package, it then filters out files the same way that the package would be distributed, which should normally be identical to a packed version of the repository files. A pure Git clone of the repository located in the project would result in something different (such as files that aren't necessary for consumers of the package), but also files that are very much needed for a developer or maintainer of the package (such as the .git directory!) Both features are complementary and fulfill different use cases.

    Thank you for the feedback and suggestions!
     
    nirvanajie and Thaina like this.
  13. spaceemotion

    spaceemotion

    Joined:
    Sep 29, 2015
    Posts:
    95
    You can already kind of do that with git submodules. You just need to update one copy and pull in all the others.
     
  14. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,166
    In the current workflow, whenever you try to edit anything that was pulled from UPM, it will often got overridden and lose. And you can't easily commit it to git. For developing package you need to have separate project. Which is not practical

    Imagine you have working on large project. You have separate some utility into separate package then include it back into your project and working with your team. Then your team found a bug in that package. Then the whole process are broken, you need to switch your package manifest url to your local, pull it into project, fix it, push it, switch back, etc, etc, etc, etc. The current workflow is totally annoying. If you really have did it you would understand so, please.

    Just try to explain to you make me recall the frustration so please
     
    Last edited: Jan 15, 2020
  15. spaceemotion

    spaceemotion

    Joined:
    Sep 29, 2015
    Posts:
    95
    We're doing the exact workflow as I described above (submodules) and there is no manifest change required so unity does not actually update or overwrite our code from new pulls. Updating the package is now as easy as pulling in the latest changes. Only for AssetStore publishing we open up the standalone project.
     
    mikeNspired and maximeb_unity like this.
  16. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,166
    That is the point you misunderstand

    The thing I suggest is that you don't require to pull latest change because the latest change would be developed in the project directly. Only the package consumer in other project or developer in other machine will need to pull it. But you who would be both the package developer and project developer won't need, the package can be seemlessly developed at the same time as the project

    We are currently talking about UPM git package, not the asset store package
     
  17. spaceemotion

    spaceemotion

    Joined:
    Sep 29, 2015
    Posts:
    95
    Not really following here as that's exactly what this allows us. Yes, the updates on other machines are not automatically done by Unity, but we're using git anyways and updating submodules just comes with a normal project pull in that case.

    1. Dev A works on a feature in a package (submodule), commits and pushes it. This updates the commit hash reference for git
    2. Dev B pulls the project, package updates automatically.
    3. Dev B works on a fix in the package, pushes it
    4. Dev A pulls, got latest changes from Dev B

    All of our UAS packages are also UPM packages (in private repos)
     
    mikeNspired likes this.
  18. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,166
    This is the point. By your workaround you just don't use UPM in your main project anymore. That's what I request it to change. We should use UPM everywhere in unity and just make it work with git directly. And then you just come to push your workaround without understanding the point. I try not to say this but please stop man

    I can workaround in anything, we can workaround in everything, but that's not a practical solution. Practical solution is unity should just adopt it as official feature

    This declare your total misunderstand about UPM

    UPM may be look like asset store package with the same folder structure and capability. But unlike asset store package, it not included directly into your asset folder. It just stay outside and just being linked into project. And so we could develop it in separate folder and separate git repo, it don't related to the project repo and don't event need to setup the submodule. Just import it into manifest and then just worked
     
  19. spaceemotion

    spaceemotion

    Joined:
    Sep 29, 2015
    Posts:
    95
    Sorry if I came across as too harsh, I was just trying to suggest an alternative, until this feature could be implemented.

    Please correct me if I am wrong, but as far as I understand it:
    - "Assets" has your project's content
    - "Library" contains all cached files as well as the downloaded packages (via the Package cache)
    - "Packages" contains the manifest and potential custom packages.

    How would you expect the suggested workflow to work when you hit "Reimport All"? If they open up the possibility to edit packages, I'd guess all your changes would be lost as the Library folder gets dropped.

    If I'm still getting it wrong, sorry.
     
    Last edited: Jan 15, 2020
  20. brunocoimbra

    brunocoimbra

    Joined:
    Sep 2, 2015
    Posts:
    679
    While I do agree with @Thaina that this would be a very helpful and desired feature, the alternative until that is real which achieves the exact same result is what @spaceemotion suggested, which is to use git submodules where both read and write is needed and leave UPM only for external read-only resources.

    I do that with different projects using the same package. Found a bug? Fix it, commit the submodule and then my team will receive the updated package once they pull the latest changes of the project. Later when I am gonna work on a different project using that same package I just pull the changes on the submodule and everything is fine.
     
  21. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,166
    My point is
    - UPM will pull the package into Library/PackageCache
    - - Which might cause some problem to edit it because it might got overridden by reimport
    - AssetStore package will pull your package directly into asset folder
    - - Which means it mess around with your project folder and repo

    I think you get my point already so, for your question, I would be preferred that "Reimport All" will not drop the PackageCache folder but just pull all package from the git source into latest version instead. And if I have edit any file in any package it would just be normally merged or become a git conflict that I could also handle conflict normally
     
  22. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    995
    In manifest file json there is dependency asset required. How do I download dependency so that is placed in required folder inside Unity project?
     
  23. henkjan

    henkjan

    Joined:
    Aug 1, 2013
    Posts:
    146
    I've created a package and linked it using Git. But when I update the repository the package in our projects don't update. Only when I remove the package and add it again (same git url) it is updated.

    Do I do something wrong or is this not supported?
     
  24. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,166
    @henkjan That's right, it's not supported, actually by design it will not update repo of the package but always using the same version you are using last time so it consistent for every build. Imagine you are using git repo of other developer and they have made breaking change, your project can be broken without your intention if it always auto updated

    And so you need to manually signal the new version of repo you want to update by yourself
     
  25. henkjan

    henkjan

    Joined:
    Aug 1, 2013
    Posts:
    146
    Ok thanks for the reply! I'm glade it's not me than :)

    About the updating, I would like it to work the same way it works for Unity's packages. Also there I can choose to update the package or not (so it's not auto updated) in the package manager. It would be nice if I got a indication that there was a new version and the decide do the update.
     
    hschulte likes this.
  26. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    @henkjan Open up manifest.json and delete the thing you want to update from the "lock" section. Then it will update automatically (but only this once - you need to do this every time).
     
    hschulte and henkjan like this.
  27. olejuer

    olejuer

    Joined:
    Dec 1, 2014
    Posts:
    211
    Loving this integration! Thank you so much.

    Actually, this is already working just fine in 2019.3 with a query parameter, for example
    Code (CSharp):
    1. "com.cysharp.unitask": "https://github.com/Cysharp/UniTask.git?path=src/UniTask/Assets/Plugins/UniTask",
    I'd like to raise again the request for a build-in update mechanism. Deleting the lock from the manifest file is pretty hands-on. If there was a protocol for the package manager to check for updates, like with native packages, that would be awesome. Otherwise I have a hard time communicating the update procedure to team members without coding background.
     
    Noxalus likes this.
  28. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    Wow. This is a game changer.

    Previously you've had to choose between "Keep everything in one repo" (much easier for development but more work when you want to publish a package) or "Separate your packages from your project" (People can easily add your packages to their project but you've got an extra job of syncing the project and package when you make changes).

    If this works as I hope it will then it makes the obvious and easy way also the right way to publish stuff.
     
    Noxalus likes this.
  29. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
    @olejuer for updating, I recommend you look into GitHub packages instead (or hosting them on Verdaccio etc). Hosting on GitHub isn't that difficult and gives the advantage of updates working "as expected".
     
    maximeb_unity likes this.
  30. olejuer

    olejuer

    Joined:
    Dec 1, 2014
    Posts:
    211
    @fherbst am I missing something here? My packages are all hosted on GitHub, as are some third-party packages I use. The package manager UI does not check for updates, or at least does not make them available. According to Unity, the only way to upgrade is to delete the lock statement from the package manifest or updating the revision manually. Did this change? Is there some config that makes the update function available in the UPM UI?

    @andybak well, this only applies if your package repo has the same privacy setting as your project repo. I would always opt for separate repos for published packages. This also keeps the git history readable and increases overall maintainability. However, "the extra job of syncing" will remain. That's exactly why I am asking for a streamlined process here.
     
  31. JesperSmith

    JesperSmith

    Joined:
    Mar 23, 2018
    Posts:
    19
    olejuer likes this.
  32. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,166
    I think the person understand it but the point is, unity should also look at git repo and check that there was new update for us to see in the Package Manager UI. So we could update from the UI instead of manually remove and add like we have done so far
     
  33. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    I think we're talking about different use cases. I'm thinking of the typical "Here's a thing I made and it comes with an example project".

    People usually publish the whole Unity project to Github - which is great as you get projectversion.txt, settings, packages etc. and it becomes *much* more likely that the thing will work for someone else. (I've learned this through bitter experience)

    But you also want a nice upm friendly url for people to easily add to existing projects.

    I think the ideal solution here is to have the repo be a full working Unity scene and give people the git package url using the path trick.
     
    olejuer likes this.
  34. JesperSmith

    JesperSmith

    Joined:
    Mar 23, 2018
    Posts:
    19
    @olejuer I'm actually running into having to upgrade git repos for some packages we use and created a tool for it

    I added an upgrade packages functionality in halodi-unity-package-registry-manager. It'll allow you to upgrade every git package (as well as registry packages). Note this is very experimental, let me know how it works. Packages from a git repo are always "upgradable", the package manager will try to pull the latest (at least in my testing).

    https://github.com/Halodi/halodi-unity-package-registry-manager
     
    Last edited: Jun 12, 2020
  35. QuantumCalzone

    QuantumCalzone

    Joined:
    Jan 9, 2010
    Posts:
    262
    Is there a way to get more detailed information about why my package can't be imported? I just get an error saying that the JSON is invalid.

    The package I'm trying to install is:
    Code (CSharp):
    1. "com.QuantumCalzone.UnityBookmarks": "https://github.com/QuantumCalzone/UnityBookmarks.git#upm"
     
    crawfis likes this.
  36. QuantumCalzone

    QuantumCalzone

    Joined:
    Jan 9, 2010
    Posts:
    262
    Just throwing this out there, but if someone could do a quick list on how to properly set up a unity project as an installable package via git I think it would be so helpful to so many people.

    I see a few examples (some listed in this thread) but reverse engineering them has failed me so far.
     
    Schneider21 and GoinPlaces like this.
  37. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    It's just JSON so any standard JSON validator should work. i.e. https://jsonlint.com/ or dozen others online.

    My guess is a missing comma at the end of that line?
     
  38. QuantumCalzone

    QuantumCalzone

    Joined:
    Jan 9, 2010
    Posts:
    262
  39. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    Hmmmm. maybe the com.QuantumCalzone.UnityBookmarks part should be all lower-case? None of the examples I can see have mixed case.
     
  40. QuantumCalzone

    QuantumCalzone

    Joined:
    Jan 9, 2010
    Posts:
    262
    OMG that was it! It's always something so simple! Thank you so much!!
     
  41. firstuser

    firstuser

    Joined:
    May 5, 2016
    Posts:
    147
    Does anyone know if there was ever an answer to this somewhere? Looked through whole thread but couldn't see any answer on native support for downgrading/upgrading packages based on semver release tags in git paths, please let me know!

    CC: @maximeb_unity @okcompute_unity
     
  42. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
    @firstuser have you tried the linked add-on? https://github.com/mob-sakai/UpmGitExtension
    So far this is not natively supported in PackMan, but mob-sakai is super active, so if you run into issues with his extension (or parts missing for your workflow) I'm sure opening an issue there would help :)
     
    firstuser likes this.
  43. firstuser

    firstuser

    Joined:
    May 5, 2016
    Posts:
    147
    Yep, thank you, explored it! It's great for what it does but in my case the setup cost and goals mean a big change would be painful down the road.

    Mainly trying to figure out which way to go long term to estimate how involved things will be before committing, so really hoping to get an answer if any native support is coming (or at least on radar.)
     
  44. AlejMC

    AlejMC

    Joined:
    Oct 15, 2013
    Posts:
    149
    Do you know if this is 2020 compatible? the upm git extension 'open window to install package' doesn't appear there.
    Can I just add the corresponding git paths themselves? (i.e. add package git url and put there UIEffect one, ParticleForUGUI, etc)

    EDIT: not true, on a fresh project it works perfectly fine. Something on my current full project is just blocking it, maybe scripts errors. Sorry for the inconveniences.
     
  45. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    Curious why Unity doesn't just include GIT in the Unity editor install now? Why would you rely on such a variable system configuration for such an essential part of projects (packages)?

    This can be a major pain point for collaborative projects, in would means you need to remember to tell people to install GIT who might join the project, even the artists. If you don't, the Editor can end up just not finishing doing anything, it gets stuck on "Waiting for Editor GUI to repaint" or for "CoreModule" to finish processing, instead of letting you know it can't finish because it can't get the dependency. And even if you remove the dependency from your manifest, it will still fail to open the project, until you also delete the existing CSPROJ file that existed for when the package was imported before.
     
  46. fherbst

    fherbst

    Joined:
    Jun 24, 2012
    Posts:
    802
    I'd recommend to use scoped registries wherever possible instead of directly using git packages. E.g. check if it's available on OpenUPM, or if you have some server hosting capabilities host your own for internal packages (we're using Verdaccio). This avoids the need for direct git URLs and instead allows proper updating of packages in Package Manager (same as for Unity's).
     
  47. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,109
    we have all our internal studio packages directly in git with all security and benefits of packagemanager
    it shows all versions and recomends updates

    The only thing that differ is dependencies.
    even without dependencies it is way more easy to manage than any npm
     
  48. alti

    alti

    Joined:
    Jan 8, 2014
    Posts:
    94
    dont just close unity hub. you gotta force quit it from task manager. otherwise it lingers.
     
  49. alti

    alti

    Joined:
    Jan 8, 2014
    Posts:
    94
    force quit all unity things from task manager and then open it up and try again.
     
  50. Thomas-Bousquet

    Thomas-Bousquet

    Joined:
    Dec 19, 2016
    Posts:
    41
    It's been 2 and a half year since this post; and this feature isn't mentioned in the official roadmap; can we get an official update on this?
     
    atomlg likes this.