Search Unity

Problems with Unity Hub CLI

Discussion in 'Unity Hub' started by mattnewport, Jun 10, 2020.

  1. mattnewport

    mattnewport

    Joined:
    Jan 29, 2016
    Posts:
    15
    I can't get the
    install-modules
    command to work with Unity Hub CLI:

    & 'C:\Program Files\Unity Hub\Unity Hub.exe' -- --headless install-modules --version 2019.3.15f1 -m android


    Results in:


    Failed to execute the command due the following, please see '-- --headless help' for assistance.
    Error: This version of the Editor could not be found. Have you tried installing it using the hub?


    But that version is definitely installed:


    > & 'C:\Program Files\Unity Hub\Unity Hub.exe' -- --headless e -i
    2019.3.15f1 , installed at C:\Program Files\Unity\Hub\Editor\2019.3.15f1\Editor\Unity.exe
    2019.4.0f1 , installed at C:\Program Files\Unity\Hub\Editor\2019.4.0f1\Editor\Unity.exe


    Other problems and weirdness I'm seeing:

    Console output is screwy on Windows in PowerShell and from cmd, instead of working like a normal console app it outputs below the prompt and then subsequent commands overwrite on top of the same output. I have to
    cls
    after every command to make sense of the output. What is it with Unity and console output on the PC? It has never worked properly in Editor batch mode either.

    Unity versions installed through the Hub CLI do not show up as installed in the Hub, they have to be manually added.

    What's with the weird extra empty argument before headless?
    -- --headless
     
  2. mattnewport

    mattnewport

    Joined:
    Jan 29, 2016
    Posts:
    15
    Some more info on what I'm seeing (this is all on Windows 10).

    Unity versions installed through the Hub CLI sometimes show up as installed in the Hub UI, sometimes they have to be manually added. When they show up automatically they offer the option to "Add Modules", "Show in Explorer" and "Uninstall" but when they don't show up and are manually added they only offer "Show in Explorer" and "Remove from Hub". In either case they are still listed when running the Hub CLI with
    --headless e -i
    .

    I can't identify any pattern to whether they show up or not. I installed 2019.3.15f1 and 2019.4.0f1 and they didn't show up. I uninstalled them both and reinstalled 2019.3.15f1 and it showed up. I thought maybe it was working after all and installed 2019.4.0f1 but it didn't show up.

    When a version shows up automatically in the Hub UI then CLI module installation seems to work. When it doesn't then CLI module installation fails with the message mentioned earlier.
     
  3. Alex_StudioDrydock

    Alex_StudioDrydock

    Joined:
    Jan 16, 2019
    Posts:
    9
    I was also trying to automate editor installs yesterday using the Unity Hub CLI and gave up trying to use it because of its broken headless mode.

    I did have success though with the Microsoft UnitySetup tools: https://github.com/microsoft/unitysetup.powershell which have a much more robust mechanism for discovering installed versions of Unity than Hub does. Being a PowerShell script, it's also easy to automate (works on Windows and Mac).

    Here's the script I use for installing the correct version of Unity for a given project: https://gist.github.com/aholkner/41929510d6b980b41903b2c612c11eea

    Hope that helps!
     
  4. RageAgainstThePixel

    RageAgainstThePixel

    Joined:
    Mar 11, 2020
    Posts:
    66
    Last edited: Jun 12, 2020
    mattnewport likes this.
  5. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,052
    @AbrahamDUnity any news on this? I have the same problems like the OP.
     
  6. BenjiM_Unity

    BenjiM_Unity

    Unity Technologies

    Joined:
    Aug 8, 2017
    Posts:
    163
    Thank you so much for the details regarding Unity Hub CLI, I’ve gone ahead and documented the conversation and shared it with the team. I'll pass along any insight or updates they may have!
     
    emerge-sjh and bdovaz like this.
  7. emerge-sjh

    emerge-sjh

    Joined:
    Oct 16, 2020
    Posts:
    14
  8. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,052
    Any news?
     
  9. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,052
    Your issue HUBX-520: [Hub] Errorlevel value is set to 1 when executing Hub CLI commands has been Resolved with the following status: As Designed and currently awaits internal confirmation.

    Resolution Notes: Works as designed. Feature improvement request. Will review with a team.

    @mattnewport Are you still experiencing the same behavior? Unity says they can't reproduce it but I don't know how to help them either.