diff --git a/lib/src/io.dart b/lib/src/io.dart
index b17d8e6e80cfc947b00349ab9ad2d3c38db95851..66b3621e0072c0d767677fd492b7742563c585f6 100644
--- a/lib/src/io.dart
+++ b/lib/src/io.dart
@@ -1060,6 +1060,8 @@ ByteStream createTarGz(List contents, {String baseDir}) {
 
         // The ustar format doesn't support large UIDs. We don't care about
         // preserving ownership anyway, so we just set them to "pub".
+        // TODO(rnystrom): This assumes contents does not contain any
+        // directories.
         var mtreeHeader = "#mtree\n/set uname=pub gname=pub type=file\n";
 
         // We need a newline at the end, otherwise the last file would get
@@ -1067,7 +1069,12 @@ ByteStream createTarGz(List contents, {String baseDir}) {
         stdin = mtreeHeader + contents.join("\n") + "\n";
       }
 
-      var process = await startProcess("tar", args);
+      // Setting the working directory should be unnecessary since we pass an
+      // explicit base directory to tar. However, on Mac when using an mtree
+      // input file, relative paths in the mtree file are interpreted as
+      // relative to the current working directory, not the "--directory"
+      // argument.
+      var process = await startProcess("tar", args, workingDir: baseDir);
       process.stdin.add(UTF8.encode(stdin));
       process.stdin.close();
       return process.stdout;
diff --git a/test/descriptor/tar.dart b/test/descriptor/tar.dart
index 03cf2a0622ff656f7d9e25a6f810aaf6c1df6f50..5c16509e9be57399c5d0660f177b3c50949135ee 100644
--- a/test/descriptor/tar.dart
+++ b/test/descriptor/tar.dart
@@ -23,8 +23,8 @@ class TarFileDescriptor extends DirectoryDescriptor
       return await withTempDir((tempDir) async {
         await Future.wait(contents.map((entry) => entry.create(tempDir)));
 
-        var createdContents =
-            listDir(tempDir, recursive: true, includeHidden: true);
+        var createdContents = listDir(tempDir,
+            recursive: true, includeHidden: true, includeDirs: false);
         var bytes =
             await createTarGz(createdContents, baseDir: tempDir).toBytes();