Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unity Package Manager can not resolve packages using git if it was installed through scoop #4317

Closed
Phothiabea opened this issue Apr 9, 2021 · 6 comments

Comments

@Phothiabea
Copy link

Phothiabea commented Apr 9, 2021

I know this is mainly a Unity Package Manager issue that appeared with one of the latest version 2020.3.2f1 where they also fixed a lot of bugs with the package manager and I also submitted a bug report to Unity but I thought I also submit it here because it specifically only happens if git was installed through scoop.

I think it may has something to do with the fact that scoop uses shims that redirect to the real git.exe but I am not sure.

Here is the issue on the Unity Bug Tracker for a detailed description: https://fogbugz.unity3d.com/default.asp?1328102_lvj454k6ub9k2kj3

Package Manager does not resolve new packages added through GIT URLs when using git installed through scoop

1. What happened
This issue always happens in both 2020.3.2f1 and the newly released 2020.3.3f1. In 2020.3.1f1 and earlier the issue does not appear.
This issue appears on machines that gave git installed through scoop. On a machine with a manual installation of git the issue did not appear.
A package added as a GIT URL either through the package manager UI or by editing the manifest.json does not resolve and instead throws the error that it could not clone the repository because it does not find the specified revision. This always fails regardless if the revision is HEAD/<branch>/<tag>/<commit hash>. This issue only happens when adding new packages. When upgrading a project from an older Unity versions, already added git packages continue to work, only new packages can not be added.

2. How can we reproduce it using the example you attached
Install git through scoop. This creates a shim for git.exe which is added to PATH instead of the real git.exe.
Open the attached project in Unity 2020.3.2f1 or 2020.3.3f1 and notice the error message on startup. In the manifest.json a small example package hosted publicly on gitlab is already added. Other git packages added from other websites fail the same regardless of their url form (git/https/ssh).

I know in a way this is an issue linked to the scoop package manager, but given that it worked before the changes to the unity package manager made in 2020.3.2f1 it might be possible the Unity Team has a better understanding on how to fix the problem.
@HUMORCE
Copy link
Member

HUMORCE commented Apr 11, 2021

tried alt-shim already?

7db0fe9

@Phothiabea
Copy link
Author

tried alt-shim already?

7db0fe9

I don't quite understand. How do I try it?

@HUMORCE
Copy link
Member

HUMORCE commented Apr 11, 2021

here: #3634 (comment)

@Phothiabea
Copy link
Author

Phothiabea commented Apr 11, 2021

Sadly did not help. Both 71 and kiennq have the same problems with Unity. It also doesn't help that Unity is not logging too precisely why it fails. It only reports that it can not find the specified commit.

@HUMORCE
Copy link
Member

HUMORCE commented Apr 12, 2021

add 'env_add_path' property to replace some filed of 'bin' property.

    "bin": [
        "usr\\bin\\tig.exe",
        "git-bash.exe"
    ],
    "env_add_path": "cmd",

I have not Unity installed, try it yourself.

@shinymerlyn
Copy link

shinymerlyn commented May 5, 2021

@HUMORCE

add 'env_add_path' property to replace some filed of 'bin' property.

Nevermind - go to the bottom that's not struck out. I got the instructions to work.

In which file? Do I need to rescan/do anything afterwards (and what command is that?)?
I see a lot of git related scoop files here when I grep my scoop dir on my hard drive, and a lot of different files that references to lines that you described in your edit.
I'm not a scoop dev or package maintainer, so not sure exactly what I should edit to try this out.

Edit:

Was it supposed to be:

    "env_add_path": "bin",

That seems to be what all the other packages mention.
When I added that to scoop/apps/git/current/manifest.json
and then did a:

scoop reset *

then C:\Users\<my username>\scoop\apps\git\current\bin\git.exe was added to my path first.

But even after this, I relaunched Unity and it still seems to be complaining with the same error as linked in the Unity FogBugz...

Edit:

Got your instructions to work.

It is indeed:

    "env_add_path": "cmd",

This is the installed copy of git.exe that Unity seems to expect, not the one in bin (as I mentioned above in the struck out text).

You also have to quit out of both Unity and Unity Hub. Unity Hub seems to get the environment when it first starts and pass it to the Unity instances you launch from there. They don't grab it fresh every time.


The instructions that worked for me:

  1. Quit out of Unity
  2. Quit out of Unity Hub
  3. Edit C:\Users\<my username>\scoop\apps\git\current\manifest.json - add "env_add_path": "cmd", just under the "shortcuts": [ .. ], section (or "bin": [ ... ], section, doesn't matter). Save the file.
  4. scoop reset *
  5. Verify that when you type where git it says C:\Users\<my username>\scoop\apps\git\current\cmd\git.exe first in the list
  6. Relaunch Unity Hub
  7. Relaunch your project that is trying to import a git package

If that still doesn't work for you, a work-around to get your dependency loaded is to clone into YourProject/Library/PackageCache/com.unity.assetbundlebrowser@b7c279278d. Look at YourProject/Packages/packages-lock.json to see the correct package id and hash prefix to use. Will have to trim the hash to some number of chars. In my case it seemed to be 10. Dunno if that's always the case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants