# GN phase failed 修复
# 报错命令
使用 OpenHarmony 源码编译,执行下面命令:
./build.sh ……
或
hb build
# 报错信息
程序报错提示下面的信息:
[OHOS INFO] ERROR at //build/config/BUILDCONFIG.gn:84:15: Could not read file.
[OHOS INFO] read_file("${preloader_output_dir}/build_config.json", "json")
[OHOS INFO] ^------------------------------------------
[OHOS INFO] I resolved this to "~/桌面/.../out/preloader/build_config.json".
[OHOS INFO] root_out_dir=//out/xxxxx
[OHOS INFO] root_build_dir=//out/xxxxx
[OHOS INFO] root_gen_dir=//out/xxxxx/gen
[OHOS INFO] current_toolchain=
[OHOS ERROR] Traceback (most recent call last):
[OHOS ERROR] File "~/桌面/.../build/hb/services/gn.py", line 176, in _execute_gn_gen_cmd
[OHOS ERROR] SystemUtil.exec_command(gn_gen_cmd, self.config.log_path)
[OHOS ERROR] File "~/桌面/xxxxx/build/hb/util/system_util.py", line 63, in exec_command
[OHOS ERROR] raise OHOSException(
[OHOS ERROR] exceptions.ohos_exception.OHOSException: Please check build log in ~/桌面/.../out/.../build.log
[OHOS ERROR]
[OHOS ERROR] During handling of the above exception, another exception occurred:
[OHOS ERROR]
[OHOS ERROR] Traceback (most recent call last):
[OHOS ERROR] File "~/桌面/.../build/hb/containers/status.py", line 47, in wrapper
[OHOS ERROR] return func(args, **kwargs)
[OHOS ERROR] File "~/桌面/.../build/hb/services/gn.py", line 178, in _execute_gn_gen_cmd
[OHOS ERROR] raise OHOSException('GN phase failed', '3000')
[OHOS ERROR] exceptions.ohos_exception.OHOSException: GN phase failed
[OHOS ERROR]
[OHOS ERROR] Code: 3000
[OHOS ERROR]
[OHOS ERROR] Reason: GN phase failed
[OHOS ERROR]
[OHOS ERROR] Solution: Please check the compile log at out/{compiling product}/build.log, If you could analyze build logs.
[OHOS ERROR] Or you can try the following steps to solve this problem:
[OHOS ERROR] 1. cd to OHOS root path
[OHOS ERROR] 2. run 'hb clean --all' or 'rm -rf out build/resources/args/.json'.
[OHOS ERROR] 3. repo sync
[OHOS ERROR] 4. repo forall -c 'git lfs pull'
[OHOS ERROR] 5. bash build/prebuilts_download.sh
[OHOS ERROR] 6. rebuild your product or component
[OHOS ERROR]
[OHOS ERROR] If you still cannot solve this problem, you could post this problem on:
[OHOS ERROR] https://gitee.com/openharmony/build/issues
[OHOS ERROR]
=====build error=====
# 解决方法
习惯把下载的文件放在桌面上了,路径里面带了中文。。。。
换成英文路径即可
究极低级问题,本来不想写到 blog 里的,但是网上搜不到解决方法,甚至有人在仓库下提了这个问题的 issue,开发者也没回,还是决定写一下