网上有很多解决方法,但是对我来说没有什么用,还是安装不成功。
所以我想到了查看错误日志,通过错误日志来把问题解决掉。
要查看 Unity Hub 的错误日志,你可以按照以下步骤操作:
Windows:
1.打开文件资源管理器:
- 按 Win + E 打开文件资源管理器。
2.导航到日志文件夹:
- 进入以下路径:
C:\Users\[你的用户名]\AppData\Roaming\UnityHub\logs
其中 [你的用户名] 是你当前登录的 Windows 用户名。
3.查看日志文件:
在 logs 文件夹中,你会看到多个日志文件,如 info-log.json 或 error-log.json。你可以用文本编辑器(如 Notepad 或 Notepad++)打开这些文件,查看详细的错误信息。
macOS:
1.打开 Finder:
点击屏幕底部的 Finder 图标。
2.导航到日志文件夹:
在菜单栏中选择 前往
> 前往文件夹...
,然后输入以下路径:
~/Library/Application Support/UnityHub/logs
- 然后点击“前往”。
3.查看日志文件:
- 进入 logs 文件夹后,你可以看到类似 info-log.json 或 error-log.json 的日志文件。用文本编辑器(如 TextEdit 或 VSCode)打开这些文件即可查看错误信息。
日志文件
也可以直接在 GUI 中打开日志文件的位置
以下是我的日志信息
{"timestamp":"2024-09-03T17:46:08.099Z","level":"info","moduleName":"Installation Manager","pid":20628,"message":"Starting installer of 2022.3.44f1-x86_64"}
{"timestamp":"2024-09-03T17:46:08.099Z","level":"info","moduleName":"Installer: 2022.3.44f1-x86_64","pid":20628,"message":"Retrying the installation of 2022.3.44f1-x86_64."}
{"timestamp":"2024-09-03T17:46:08.099Z","level":"info","moduleName":"Installer: 2022.3.44f1-x86_64","pid":20628,"message":"Exiting from State: Failed. Event: RETRY"}
{"timestamp":"2024-09-03T17:46:08.099Z","level":"info","moduleName":"Installer: 2022.3.44f1-x86_64","pid":20628,"message":"Transition to state \"install_validation\" on event \"RETRY\""}
{"timestamp":"2024-09-03T17:46:08.100Z","level":"info","moduleName":"Installer: 2022.3.44f1-x86_64","pid":20628,"message":"Entered State: install_validation"}
{"timestamp":"2024-09-03T17:46:08.101Z","level":"info","moduleName":"UnityIPCServer","pid":20628,"message":"IPC Server Unity-hubInstallServer started"}
{"timestamp":"2024-09-03T17:46:08.101Z","level":"info","moduleName":"UnityInstallerWindows","pid":20628,"message":"spawn child process, elevated: true"}
{"timestamp":"2024-09-03T17:46:08.101Z","level":"info","moduleName":"UnityInstallerWindows","pid":20628,"message":"executing \"D:\\Program Files\\Unity Hub\\Unity Hub.exe\" -- --winInstaller"}
{"timestamp":"2024-09-03T17:46:08.169Z","level":"info","moduleName":"UnityInstallerWindows","pid":20628,"message":"user did not agree to the UAC prompt and the process was not started"}
{"timestamp":"2024-09-03T17:46:08.170Z","level":"info","moduleName":"UnityIPCServer","pid":20628,"message":"IPC server Unity-hubInstallServer closed"}
{"timestamp":"2024-09-03T17:46:08.170Z","level":"error","moduleName":"UnityInstallerWindows","pid":20628,"message":"{ code: 'User did not grant permission.', message: 'The Hub does not have proper permissions to install Unity.' } 'powershell.exe' is not recognized as an internal or external command,\r\noperable program or batch file.\r\n "}
{"timestamp":"2024-09-03T17:46:08.170Z","level":"info","moduleName":"Installer: 2022.3.44f1-x86_64","pid":20628,"message":"Validation FAILED."}
{"timestamp":"2024-09-03T17:46:08.170Z","level":"info","moduleName":"Installer: 2022.3.44f1-x86_64","pid":20628,"message":"Exiting from State: Validation. Event: ERROR"}
{"timestamp":"2024-09-03T17:46:08.170Z","level":"info","moduleName":"Installer: 2022.3.44f1-x86_64","pid":20628,"message":"Transition to state \"install_failed\" on event \"ERROR\""}
{"timestamp":"2024-09-03T17:46:08.170Z","level":"info","moduleName":"Installation Manager","pid":20628,"message":"Update: install_failed"}
{"timestamp":"2024-09-03T17:46:08.171Z","level":"info","moduleName":"Installer: 2022.3.44f1-x86_64","pid":20628,"message":"Entered State: install_failed"}
根据我的的日志信息,Unity Hub 在尝试安装 Unity 版本 2022.3.44f1 时遇到了以下问题:
1. 用户未同意 UAC 提示:
日志中提到 “user did not agree to the UAC prompt and the process was not started”,这意味着在安装过程中,Windows 弹出了一个 UAC(用户帐户控制)提示,要求管理员权限,然后我没有授予权限,导致安装失败。
事实上我安装的时候根本就没有弹出提示。
2. 权限问题:
日志还指出 “The Hub does not have proper permissions to install Unity.”,这进一步确认了 Unity Hub 缺乏必要的权限来进行安装操作。
3.PowerShell 命令无法识别:
日志中提到 “powershell.exe’ is not recognized as an internal or external command”, 表示系统未能识别 powershell.exe。这可能意味着系统环境变量中缺少 PowerShell 的路径,或者 PowerShell 安装存在问题。
解决方案
1. 授予 UAC 权限:
右键点击 Unity Hub 图标,选择“以管理员身份运行”,然后再次尝试安装。
2. 检查 PowerShell 路径:
确保 PowerShell 已正确安装,并且在系统的环境变量 PATH 中有正确的路径。通常情况下,PowerShell 应该位于 C:\Windows\System32\WindowsPowerShell\v1.0\ 路径下。可以通过以下步骤手动添加这个路径:
- 右键点击“此电脑”或“计算机”图标,选择“属性”。
- 点击“高级系统设置”,然后点击“环境变量”。
- 在“系统变量”中找到 Path,点击“编辑”。
- 确认 C:\Windows\System32\WindowsPowerShell\v1.0\ 在路径列表中。
至此,经过以上两个操作,已经可以正常下载安装了。
标签:info,09,Hub,failed,timestamp,level,Failed,message,20628 From: https://blog.csdn.net/weixin_50681225/article/details/141875781