Skip to content

Commit cc58dc5

Browse files
committed
[BE] Remind users to update submodule
Summary: As titled. This adds messages when we suspect the user forgot to update git submodule or cleanup the CMake cache. Test Plan: See the following error messages Reviewers: Subscribers: Tasks: Tags: ghstack-source-id: 4021ed8 Pull Request resolved: #8203
1 parent e63c923 commit cc58dc5

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

setup.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
import setuptools # noqa: F401 # usort: skip
5858

5959
from distutils import log
60+
from distutils.errors import DistutilsExecError
6061
from distutils.sysconfig import get_python_lib
6162
from pathlib import Path
6263
from typing import List, Optional
@@ -638,7 +639,22 @@ def run(self):
638639
# lists.
639640

640641
# Generate the build system files.
641-
self.spawn(["cmake", "-S", repo_root, "-B", cmake_cache_dir, *cmake_args])
642+
try:
643+
self.spawn(
644+
["cmake", "-S", repo_root, "-B", cmake_cache_dir, *cmake_args]
645+
)
646+
except DistutilsExecError as e:
647+
error = str(e)
648+
# Our educated guesses from parsing the error message.
649+
additional_log = ""
650+
# 1. Prelude related errors, could be related to third-party/prelude pin out of sync
651+
# 2. Missing source file, could be related to git submodules not synced or cmake cache is outdated
652+
if "third-party/prelude" or "Cannot find source file" in error:
653+
additional_log += "ExecuTorch: \033[31;1mEither CMake cache is outdated or git submodules are not synced.\033[0m\n"
654+
additional_log += "ExecuTorch: \033[31;1mPlease run the following before retry:\033[0m\n"
655+
additional_log += "ExecuTorch: \033[32;1m./install_executorch.sh --clean\033[0m\n"
656+
additional_log += "ExecuTorch: \033[32;1mgit submodule update --init --recursive\033[0m\n"
657+
raise Exception(error + "\n" + additional_log) from e
642658

643659
# Build the system.
644660
self.spawn(["cmake", "--build", cmake_cache_dir, *build_args])

0 commit comments

Comments
 (0)