manifest_file must be an absolute path

Correctly pass the full path of the manifest file for the submanifest.
The manifest-name in the <submanifest/> element was being passed in
as given, which caused it to not be found since the current directory
never set. (b/226333721: fails when manifest-name is given.)

Also verify that the manifest_file passed to XmlManifest() is an
absolute path.

Change-Id: I23461078233e34562bc2eafeb732cfe8bd38ddc1
Tested-by: LaMont Jones <>
Reviewed-by: Mike Frysinger <>
diff --git a/ b/
index fa3e103..a14cc52 100644
--- a/
+++ b/
@@ -237,8 +237,13 @@
     if self.remote and not self.project:
       raise ManifestParseError(
           f'Submanifest {name}: must specify project when remote is given.')
+    # Construct the absolute path to the manifest file using the parent's
+    # method, so that we can correctly create our repo_client.
+    manifestFile = parent.SubmanifestInfoDir(
+        os.path.join(parent.path_prefix, self.relpath),
+        os.path.join('manifests', manifestName or 'default.xml'))
     rc = self.repo_client = RepoClient(
-        parent.repodir, manifestName, parent_groups=','.join(groups) or '',
+        parent.repodir, manifestFile, parent_groups=','.join(groups) or '',
         submanifest_path=self.relpath, outer_client=outer_client)
     self.present = os.path.exists(os.path.join(self.repo_client.subdir,
@@ -337,6 +342,8 @@
     self.repodir = os.path.abspath(repodir)
     self.topdir = os.path.join(os.path.dirname(self.repodir), submanifest_path)
+    if manifest_file != os.path.abspath(manifest_file):
+      raise ManifestParseError('manifest_file must be abspath')
     self.manifestFile = manifest_file
     self.local_manifests = local_manifests
     self._load_local_manifests = True