diff --git a/tools/gen_buildinfo.py b/tools/gen_buildinfo.py
index d01b7829f6340cae7150de341476fd1ccb0784d4..4e4a900e7efcd8ec4bf1fc1d097452e1f3af055d 100644
--- a/tools/gen_buildinfo.py
+++ b/tools/gen_buildinfo.py
@@ -3,10 +3,16 @@
 with open("buildinfo_pkg.vhd", "w") as f:
   import subprocess
   import time
-  commitid = subprocess.check_output(
+  try:
+    commitid = subprocess.check_output(
       ["git", "log", "-1", "--format=%H"]).decode().strip()
-  userid = subprocess.check_output(
+  except:
+    commitid = "unknown"
+  try:
+    userid = subprocess.check_output(
       ["git", "config", "--get", "user.name"]).decode().strip()
+  except:
+    userid = "unknown"
   if action == "simulation":
       top = sim_top
       tool = sim_tool