Search Unity

Git support on Package Manager

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

  1. Ooctopus

    Ooctopus

    Joined:
    May 28, 2019
    Posts:
    4
    Thank you but that's not my question.

    I would to know what I need to do to import the external package of this project, because at this time if I just clone/download the project and import it in Unity there are some missing files...
     
  2. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    Tell us exactly what you're doing and what the errors/missing files are.

    As far as I know - assuming git is already installed on your system - it should be as simple as opening the downloaded project via the Unity Hub.
     
  3. LennartJohansen

    LennartJohansen

    Joined:
    Dec 1, 2014
    Posts:
    2,394
    Is there any way to get the package manager to check for new versions of the git project. Allow you to update like with the Unity packages?

    Lennart
     
    Lars-Steenhoff likes this.
  4. Rotary-Heart

    Rotary-Heart

    Joined:
    Dec 18, 2012
    Posts:
    813
    Manually, you can. Just delete the lock that appears at the end of the packages file. They should include a section on the package manager that indicates if there's any update on that package and let the user update it.
     
  5. Elringus

    Elringus

    Joined:
    Oct 3, 2012
    Posts:
    483
    Hey @okcompute_unity @maximeb_unity,

    Thank you guys for your work and the communication here!

    A question, if I may. Afaik, it was planned to add UI for Git dependencies in 2019.1, but in the manual it's now mentioned that installing a Git repo via Packages window is impossible. Does that mean you've decided to not add the UI for remote dependencies, or is it still in the works (what's the new ETA, in case it's the latter)?
     
  6. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,164
    @Elringus I think we don't rely on unity version to expect a feature anymore. The git support API will be added (or not) from the Package Manager package itself, not related to unity version. So they might still doing it, but the unity 2019 just already launched because it was not related and depend on each other anymore
     
  7. MaskedMouse

    MaskedMouse

    Joined:
    Jul 8, 2014
    Posts:
    1,092
    I seem to run into a problem with git LFS on MacOSX...
    On Windows everything goes fine but on Mac it can't seem to find git lfs even though when I run a terminal 'git lfs version' returns its version 2.7.2
    I've installed git lfs via brew and initialized it, but still it won't budge. Anything I might've forgotten to config?

    MacOSX LFS error.png
     
  8. Tsequier

    Tsequier

    Joined:
    Apr 20, 2016
    Posts:
    23
    Hello, I've managed to make everything work as I wanted, but one thing remain on the git setup side of the thing.
    When I look at, for example, Keijiro's repo (like this recent one https://github.com/keijiro/Rsvfx), he has (minimum) 2 branches, one with the full unity project, like master, and another one called upm which one has the necessary file for the package at the root. Does one of you know how to set up something like that with git ? Is it several .gitignore, or something like subtree or submodule (I'm not very knowledgeable about git)? Thanks !
     
  9. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    I investigated complex ways to achieve this with git subtree and sparse checkouts and came to the conclusion it's better just to maintain the two branches manually. Git terrifies me once you get off the beaten track - it's ability to become a task in itself separately from the problem you're actually trying to solve is unparalleled outside of maybe the morbid allure of regular expressions.
     
  10. Tsequier

    Tsequier

    Joined:
    Apr 20, 2016
    Posts:
    23
    @andybak Thank you, I absolutely agree with your statement regarding git, so I am going to do it manually as well !
     
  11. misher

    misher

    Joined:
    Apr 22, 2016
    Posts:
    19
    Hi.
    I've tried to add a git package, this one: https://github.com/kolodi/com.kolodi.unity-goodies
    But I have errors.

    When typing simply "https://github.com/kolodi/com.kolodi.unity-goodies" it says:
    Cannot perform upm operation: Unable to add package ["https://github.com/kolodi/com.kolodi.unity-goodies"]: 
    Package name '"https://github.com/kolodi/com.kolodi.unity-goodies"' is invalid. [InvalidParameter]


    So I've tried "https://github.com/kolodi/com.kolodi.unity-goodies.git". It worked for some instants on and the I have the following error message:
    Cannot perform upm operation: Unable to add package [https://github.com/kolodi/com.kolodi.unity-goodies.git]:
    Error when executing git command. fatal: 'submodule' appears to be a git command, but we were not
    able to execute it. Maybe git-submodule is broken? [NotFound]


    Then I cloned the repo to my local machine and was able to add package from disk without any issue.

    I'm using latest (at this moment) Unity: 2019.3.0a8
     
  12. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    It likely is somewhere already answered but I was not able to quickly find this information:
    • How to I provide all published versions via the package manager and not only the one specified via the git url/specific tag?
    • Is it already possible to set up custom urls for the 3 links hardcoded (the last thing I have read somewhere was "plannet but not in yet - on the timeline for 2020")
     
  13. Karashi-shiki

    Karashi-shiki

    Joined:
    Jul 9, 2019
    Posts:
    3
    Last edited: Jul 12, 2019
  14. misher

    misher

    Joined:
    Apr 22, 2016
    Posts:
    19
    Issue resolved! You should add git bin folder path to the PATH variable on Windows. In my case it was: "C:\Program Files\Git\bin". Without it, "git submodule" command doesn't work.
     
  15. manu73

    manu73

    Unity Technologies

    Joined:
    Aug 22, 2014
    Posts:
    68
    Hi @misher!

    GIT support (including SSH urls) for packages is now available in Unity 2019.3.0a10.

    Regards,

    Manu.
     
    EirikWahl, jilleJr, NSXboxDev and 7 others like this.
  16. Vapid-Linus

    Vapid-Linus

    Joined:
    Aug 6, 2013
    Posts:
    64
    This Patreon post explains how to do it:
    https://www.patreon.com/posts/25070968
     
    takashi-sakai likes this.
  17. localprojects

    localprojects

    Joined:
    Apr 26, 2019
    Posts:
    8
    Hi,
    I can see the files in my custom package and seems to be imported correctly, but I can seem to access the classes?

    Do you know what might be happening?

    Im using this custom package to get started:
    "com.namespace.unitypackageexample": "https://github.com/neogeek/unity-package-example.git#upm"
     
  18. jilleJr

    jilleJr

    Joined:
    Jan 21, 2015
    Posts:
    63
    With a brief look it seems correct. Good minimal example. What error are you getting? Double-check the Library/PackageCache to see if it's the correct version.
     
  19. keattikorn

    keattikorn

    Joined:
    Feb 19, 2014
    Posts:
    3
    The UPM still does not resolve the Git-LFS object through the hashed link. A temp solution is to not use LFS object in the custom-made package.
     
  20. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    554
    Hi keattikorn,

    This has been fixed in Unity 2019.3. The problem was that the folder where brew installs Git LFS (
    /usr/local/bin
    ) is not included in the PATH environment variable when Unity starts.

    Here's two workarounds:
    - If you have root access, you can create a symlink from
    /usr/bin/git-lfs
    to
    /usr/local/bin/git-lfs
    . To do so, run the following command in the terminal:
    Code (CSharp):
    1. ln -s /usr/local/bin/git-lfs /usr/bin/git-lfs
    - If not, or if you prefer not to modify
    /usr/bin
    , you can open Unity from a terminal or a script, either of which should load your user environment settings including a modified PATH environment variable (which explains why Git LFS works fine on the command-line). This is less practical, but if you use a script, you can still launch Unity with a double-click, if you don't mind the extra Terminal window opening. (Note that the Hub must not be running for this to work.)
     
    Thaina likes this.
  21. keattikorn

    keattikorn

    Joined:
    Feb 19, 2014
    Posts:
    3
    Thank you for your reply. I am going to try your described method on my Mac.

    What's is a solution on Windows 10? I use both Mac and Windows regularly.
     
  22. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    554
    Windows handles environment variables and program paths differently. Normally if Git LFS works on the command-line, then it means that the git-lfs.exe program is accessible by one of the paths configured in the PATH environment variable, so it will work in Unity as well. The issue I mentioned was fixed in 2019.3 was on MacOS/Linux only.

    If Git LFS does not work when using Git on the command-line, make sure the path to the directory containing the Git LFS executable is listed in your Windows PATH environment variable.
     
  23. Maras

    Maras

    Joined:
    Dec 11, 2012
    Posts:
    131
    Just want to say thank you. Package Manager is pretty amazing. :)

    +1 for GitHub subfolder, would be really useful.
     
    ainaruth and maximeb_unity like this.
  24. keenanwoodall

    keenanwoodall

    Joined:
    May 30, 2014
    Posts:
    598
    Apologies if this has already been discussed, but I couldn't find anything on it. I've got a package with some code inside it that I'd like to move into a separate "sub" package. I put the code into a new repo and threw it up on github as a separate package. After that I added a dependency to the new package (via url to a specific commit) on the main package. When I added the main package to a test project via disk reference I got this error
    upload_2019-10-11_18-22-20.png
    Everything looks good to me so (assuming I didn't goof anything up) I was curious if packages support references to git urls. The reason I suspect I haven't messed anything up is b/c when adding the dependency to the main projects manifest, it was loaded correctly.

    main package.json:
    {
    "name": "com.beans.deform",
    "author": "Keenan Woodall",
    "displayName": "Deform",
    "version": "1.0.3",
    "unity": "2018.3",
    "description": "A framework for deforming meshes in the editor and at runtime.",
    "category": "Unity",
    "keywords":
    [
    "burst",
    "mathematics",
    "mesh",
    "modifiers",
    "deformers"
    ],
    "dependencies":
    {
    "com.unity.burst": "1.1.2",
    "com.unity.mathematics": "1.1.0",
    "com.beans.unity.collections": "https://github.com/keenanwoodall/Be....git#46c13d356f760956ddee0707a8500a54522b9352"
    }
    }
    sub package.json:
    {
    "name": "com.beans.unity.collections",
    "author": "Keenan Woodall",
    "displayName": "Collections Extensions",
    "version": "0.0.0-preview",
    "type" : "tool",
    "unity": "2018.3",
    "description": "Various extensions and utilities for native collections.",
    "category": "Unity",
    "keywords":
    [
    "mathematics"
    ],
    "dependencies":
    {
    "com.unity.mathematics": "1.1.0-preview"
    }
    }
     
  25. bddckr

    bddckr

    Joined:
    Sep 13, 2016
    Posts:
    28
    keenanwoodall likes this.
  26. Fangh

    Fangh

    Joined:
    Apr 19, 2013
    Posts:
    274
    Hello.
    I created my package.json and uploaded it on my gihub.
    But I don't understand how to add this package to my project because in the package manager there is only a "Add Package From Disk". I can't choose to add a package from my github https://github.com/Thomas-6freedom/PirateToolChest

    How to add a package in my project from my github ?
     
  27. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    @Fangh add the url by hand into the manifest.json
     
  28. bddckr

    bddckr

    Joined:
    Sep 13, 2016
    Posts:
    28
  29. starikcetin

    starikcetin

    Joined:
    Dec 7, 2017
    Posts:
    340
    Try this: https://github.com/mob-sakai/GitDependencyResolverForUnity
     
    keenanwoodall likes this.
  30. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    826
    Hey there,

    I really enjoyed using packages until I got a problem with out of the blue, that git can't be found (on two different PCs), even though on both of them git is installed.

    I tried opening the project with 2019.3.0f1, but it didn't work.
    I also created a clean new project, but as soon as I add a simple dependency like upm-git-extension
    "com.coffee.upm-git-extension": "https://github.com/mob-sakai/UpmGitExtension.git#1.0.1"

    I get this:
    upload_2019-12-3_9-17-36.png

    About the Setup
    Unity: 2019.3.0f1, 2019.2.10f1
    UnityHub: 2.2.1
    Windows: Windows10 Pro 1909

    Git:
    Code (cmd):
    1. C:\>git --version
    2. git version 2.24.0.windows.2
    3. C:\>git-lfs --version
    4. git-lfs/2.9.0 (GitHub; windows amd64; go 1.12.7; git 8ab05aa7)
    Environment variables:
    C:\Program Files\Git\cmd
    C:\Program Files\Git\bin (Added afterwards since somebody mentioned it here)

    As an obedient windows user I of course also tried restarting the computer.
    I had no problems for the last 4 months using the package manager with custom packages, where do those problems come from? Anyone experiencing something similar and solved it? :S
     
    Last edited: Dec 4, 2019
  31. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,164
    Quick guess is environment variable

    Most program normally find git with environment variable not by cmd

    And it might need restart if env just changed
     
  32. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    826
    Thanks for the response. Yep, that would make sense, but I have set the environment variables and it worked without a problem for months.
    Or did you set different variables? They are set as system variables (in PATH), not as user variables. Is that an issue?
     
  33. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,164
    I also only have `C:\Program Files\Git\cmd` in my system PATH variable

    But maybe order matter. Might you try moving that path to the top or bottom and restart
     
  34. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    826
    Sadly that is not the problem. I did have "C:\Program Files\Git\cmd" as the only path as well and added the second path to try to fix the problem after it occured. Actually, on one machine I still just have the path "C:\Program Files\Git\cmd" as the only set path.

    I tried a few more different approaches and found a strange solution: When starting the unity outside of the UnityHub, the package manager can access git and can pull the git repos. Strangly the package manager ui does not support selecting different versions in that case:
    upload_2019-12-4_11-44-11.png

    I also tried deleting the Hub (also with Revo Uninstaller), sadly without any luck. I opened a thread in the unity hub subforum: https://forum.unity.com/threads/unityhub-breaks-git-path-for-package-manager.788096/


    TLDR: Open the project with the unity version directly instead of using the hub kind of works for me.
     
    Last edited: Dec 4, 2019
  35. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,164
    As of your describing I feel like current version of unityhub has a bug that overriding env variable and make a path variable missing from its env
     
  36. spaceemotion

    spaceemotion

    Joined:
    Sep 29, 2015
    Posts:
    95
    The Unity Hub definitely messes with the env variables, since you need to restart it when you edit any of them (e.g. PATH). Restarting ONLY the Editor does not work, if the Hub is still running in the background.
     
  37. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    826
    Thanks for the info. I did try multiple times to kill the hub and restart my computer, I guess in my case there is a different cause.
    Another thought I have: When I open the project directly through the editor exe while having the hub running as well, the git problem does not appear. And as I said, I have the problem on two different systems for newly created seperate projects.
     
    Noxalus likes this.
  38. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,164
    What I mean is, the hub does not really change the system env directly, it could not

    Bu every process that was opened could override its own env variable, like putting a stack on top of each other. And all the subprocess opened from it, and subprocess of the subprocess, will inherit those overridden env variable
     
  39. Noxalus

    Noxalus

    Joined:
    Jan 9, 2018
    Posts:
    80
  40. bonannialberto

    bonannialberto

    Joined:
    Apr 19, 2019
    Posts:
    5
    How did you solve this? I am also trying to call Rsvfx via manifest but the link seems incorrect.
     
  41. Johannski

    Johannski

    Joined:
    Jan 25, 2014
    Posts:
    826
    To get a fancy UPM branch, you can follow this tutorial: https://www.patreon.com/posts/25070968


    Now that I installed UnityHub 2.2.2 git is running again as it should, thanks for the fix!

    I'm wondering however, the package manager window does not show any other versions for my projects, is this expected?

    Cheers Johannes
     
  42. Rafael_CS

    Rafael_CS

    Joined:
    Sep 16, 2013
    Posts:
    162
    Same problem here =(
     
  43. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    Hello, this may have been already asked, but how can I manage a repository that has the package.json file not on the root folder?
     
  44. starikcetin

    starikcetin

    Joined:
    Dec 7, 2017
    Posts:
    340
  45. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    it worked, but it ignores the dependencies in the package file, is that normal?
     
  46. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
  47. starikcetin

    starikcetin

    Joined:
    Dec 7, 2017
    Posts:
    340
    No, I have been using this method for a while and dependencies are working fine for me.
     
  48. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    probably you declare 3rd party github dependencies as git URLS too , right?
     
  49. starikcetin

    starikcetin

    Joined:
    Dec 7, 2017
    Posts:
    340
    Exactly
     
  50. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    I didn't try, but as far as I understood :

    However, UPM does not support git urls as dependencies in the package. :(

    [ package-a/package.json ]
    {
    "name": "com.coffee.package-a",
    "version": "0.1.0",
    "dependencies": {
    "com.coffee.core-a" : "https://github.com/mob-sakai/GitPackageTest#core-a-0.1.0"
    }
    }

    this was not supported, is it now?