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
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.
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!
Yeah the unitysetup.powershell does a recursive search but it can be slow. I was looking at adding hub support to it. Here's what I have so far: https://github.com/StephenHodgson/UnityCI/blob/master/InstallUnityHub.ps1 Should work for mac and windows, but there's still problems with the linux hub installer, and I haven't been able to figure out how to properly install it in powershell. Hope this helps Cheers,
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!
@BenjiM_Unity This thread is related. Exit codes returning 1 when it seems the execute correctly This thread is also related. Headless mode really isn't headless.
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.