Search Unity

Package from Git URL shows LFS Pointer file instead of actual content

Discussion in 'Package Manager' started by RoaBen, Oct 23, 2020.

  1. RoaBen

    RoaBen

    Joined:
    Feb 13, 2019
    Posts:
    5
    Hello everyone, I have a problem with a custom package that we're working on for our customer. I've studied the documentation thoroughly but I cannot seem to find a solution.

    Our setup consists of two Unity Projects that use Unity 2020.1.4f1:

    Project A is the project that we work on the package in
    <Unity project folder>/Packages/com.mycompanyname.something/
    and is hosted on Github.

    Project B expects this package in it's manifest.json
    Code (json):
    1. {
    2.     "dependencies": {
    3.             "com.mycompanyname.something": "https://github.com/mycompanyname/reponame.git?path=/Packages/com.mycompanyname.something"
    4.     }
    5. }
    While we do not have any problems using Git LFS while pulling/pushing Project A, Project B loads the package but all files tracked with LFS just show the pointer files and not the actual files.

    This suggests to me that Git LFS is not triggered by the way the package manager pulls packages from Github.

    This command in bash tells me I have only one git-lfs.exe on my pc (/c/Program Files/Git LFS/git-lfs):
    where git-lfs


    This tells me that it is also using this exact file(/c/Program Files/Git LFS/git-lfs):
    which git-lfs


    This tells me that GIT_LFS_PATH=C:\Program Files\Git LFS is correct:
    git-lfs env


    I attached an extract from the Editor.log where it resolves the packages. Nothing interesting to see here.

    Could this have something to do with administrative permissions or any other windows permissions in general?

    I wonder, why is Project B unable to resolve the files tracked by lfs and instead loads the lfs pointer files?
     

    Attached Files:

    Last edited: Oct 23, 2020
    Petr777 and The_Swiss_Guy like this.
  2. supita_unity

    supita_unity

    Unity Technologies

    Joined:
    Dec 13, 2019
    Posts:
    226
  3. RoaBen

    RoaBen

    Joined:
    Feb 13, 2019
    Posts:
    5
    Thank you for your quick reply! After upgrading to 2020.1.10f1 I get a different error. After a fixed duration of about 2 minutes of resolving packages, I automatically get this:



    It seems to me that it now starts resolving via Git LFS but does not wait for it to be finished but instead after 2 minutes prompts this error (I have a slow internet connection).

    Edit: It seems my problem is this: https://issuetracker.unity3d.com/is...-requires-exclusive-access-to-the-project-dot
     
    Last edited: Oct 26, 2020
  4. supita_unity

    supita_unity

    Unity Technologies

    Joined:
    Dec 13, 2019
    Posts:
    226
    Hello again, I'm so sorry you are hitting this 2nd issue. We are actively working on a solution for this timeout problem, we found already the source of this problem and a fix will be landing soon.
     
  5. jason_yak

    jason_yak

    Joined:
    Aug 25, 2016
    Posts:
    531
    I'm hitting this issue in 2020.3.14, and in the comments on that issue track you'll see someone with the issue in the latest LTS version as well, time of writing is 2020.3.16. I've tried enabling git lfs cache in upm user config file on macos, it's not changing the outcome. My files that are stoed in lfs are showing a few lines git lfs related text instead of their proper contents.
     
  6. supita_unity

    supita_unity

    Unity Technologies

    Joined:
    Dec 13, 2019
    Posts:
    226
    Hey, I'm really sorry you are having this issue, I'm not sure if the source of the problem is the same that the originally fixed one, it would be super helpful if you can submit a bug with all the possible information about it. The page detailing the bug reporting process can be found here: https://unity3d.com/unity/qa/bug-reporting.

    If you could change the Package Manager Log Level to “Silly” before submitting the bug. This option can be found under Preferences, in the General tab.
    upload_2021-9-1_14-15-6.png

    You can share the case number here once you submit the bug and I can follow up on it.

    Thanks in advance!
     
  7. arnaldoGaroto

    arnaldoGaroto

    Joined:
    Feb 3, 2013
    Posts:
    22
    I had a similar error about corrupt PNGs from a package. I fixed it reinstalling git lfs:
    brew install git-lfs
     
  8. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
  9. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    556
    Hi @thefallengamesstudio, that bug was fixed a while ago. If I understand correctly, you are still running into that issue in a more recent version of the Editor? (2021.3.18f1) If so, can you provide repro steps (maybe a specific small Git repository containing a dummy package we can use in a repro) so that we can track that regression and address it?
     
    Last edited: Feb 14, 2023
  10. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Hey! Yes, correct. Where should I send it?

    Meanwhile, the particularities are:
    - package's master branch is a normal Unity project with a "Assets/upm" folder, and a .gitattributes at the root
    - on release, I use git subtree to create a vX.Y.Z-upm branch that only contains the "Assets/upm" directory's contents
    - on the consumer side, the package is declared as
    "com.<company>.<product>": "https://<token>@github.com/<user>/<repo>.git#v0.5.4-upm"


    I have a feeling that just going over this list could give you a hint as to why it's not working, because it's an otherwise regular package, just some images and scripts
     
  11. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    556
    What repo is Git subtree used with? I assume it's a different repo intended for releases of your package? Does the vX.Y.Z-upm branch also contain the .gitattributes file? It has to be present in every branch that uses Git LFS files, not only the main/master branch.
     
    xucian likes this.
  12. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Nope, same repo. Reason is: have a branch with just that Assets/upm/* content at the root, to not need to add the path argument into the url.

    But you make a very good point I oversaw.. with my setup, there won't be any .gitattributes in the resulted branch, since that subfolder's content replaces everything in the repo now.
    Good point! Hope this helps others that are in the same situation
     
  13. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    556
    If you do this via a script, all you need to add is something like this after creating the substree:

    Code (CSharp):
    1. git checkout master -- .gitattributes # maybe other "repo root" files, if any are needed
    2. git add .gitattributes
    3. git commit -m "Add Git repo files to release"
    BTW, your setup is pretty clever, I never thought of using subtrees in the same repo to "move" things around. That's a very interesting approach. It has some gotchas though; aside from .gitattributes, there may other files you want to add, like .gitignore (or maybe not, since your branch is actually more or less immutable branch... in which case, tags could be an option too, if you want to avoid polluting your list of branches).

    So just to be sure, this missing .gitattributes file in your branch is what was causing the issue, right?
     
    bleater likes this.
  14. bleater

    bleater

    Joined:
    Apr 19, 2012
    Posts:
    28
    Faced the same problem, and same solution; copying .gitattributes into the root of the UPM package created by git subtree split fixed the issue with git lfs not fetching the lfs file contents. Thanks.
     
    xucian likes this.
  15. xucian

    xucian

    Joined:
    Mar 7, 2016
    Posts:
    846
    Sorry, not sure what happened when I tried to reply at the time, but yes, you're correct. Copying that file fixes it!
     
    maximeb_unity likes this.
  16. BSimonSweet

    BSimonSweet

    Joined:
    Aug 17, 2022
    Posts:
    67
    Hi !

    I'm facing this issue right now. I add a package from a private GitHub repo and LFS files are not resolved, only the pointer is pulled.

    I install the package with a specific branch, in the URL (ex :
    https://github.com/MyOrg/MyRepo.git#develop
    ). The
    .gitattributes
    file is at the root of the package, in the same folder as the
    package.json
    file. And I have Git LFS installed on my PC (Windows 11).

    None of the solution in this thread or in the documentation works ...
     
    Petr777 and xucian like this.