From b1ca2b72b1b23bf5a0bf16bf816d684cc809b3a2 Mon Sep 17 00:00:00 2001
From: Natalie Weizenbaum <nweiz@google.com>
Date: Tue, 14 Jul 2015 12:58:52 -0700
Subject: [PATCH] Pass an absolute package root to the VM.

This is helpful for subprocesses to be able to spawn Dart with
Platform.executableArguments and have that work regardless of the
working directory.

R=rnystrom@google.com

Review URL: https://codereview.chromium.org//1236973002 .
---
 lib/src/executable.dart | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/lib/src/executable.dart b/lib/src/executable.dart
index 863f306f..62c33a1c 100644
--- a/lib/src/executable.dart
+++ b/lib/src/executable.dart
@@ -115,7 +115,12 @@ Future<int> runExecutable(Entrypoint entrypoint, String package,
   // example, it may not have the right packages directory itself.
   if (executableUrl.scheme == 'file' || executableUrl.scheme == '') {
     // TODO(nweiz): use a .packages file once sdk#23369 is fixed.
-    vmArgs.add('--package-root=${p.toUri(entrypoint.packagesDir)}');
+
+    // We use an absolute path here not because the VM insists but because it's
+    // helpful for the subprocess to be able to spawn Dart with
+    // Platform.executableArguments and have that work regardless of the working
+    // directory.
+    vmArgs.add('--package-root=${p.toUri(p.absolute(entrypoint.packagesDir))}');
   }
 
   vmArgs.add(executableUrl.toString());
-- 
GitLab