Skip to content

Commit

Permalink
[beta] [ Service ] Include drive letter in path when launching DDS sn…
Browse files Browse the repository at this point in the history
…apshot

The previous logic for building the path to dds.dart.snapshot would result
in the Windows drive letter being dropped from the path:

\path\to\dart-sdk\bin\dds.dart.snapshot

This works most of the time since a leading slash is treated as a reference
to the current drive, which often contains the Dart SDK. However, if the SDK
is on a different drive than the current (e.g., in a container with two drives),
the VM will fail to find the snapshot.

This change uses the File(...) APIs from dart:io to build the path rather than
trying to use the Uri class to manually hack together a path.

TEST=N/A, not reproducible without a second Windows drive

Bug: grpc/grpc-dart#697
Change-Id: I71d00b07a98508a780f5aab76417da4aa530f3c4
Cherry-pick: https://dart-review.googlesource.com/c/sdk/+/360920
Cherry-pick-request: #55386
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/361400
Reviewed-by: Siva Annamalai <[email protected]>
  • Loading branch information
bkonyi committed Apr 12, 2024
1 parent 9bf485f commit 66b9bf5
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions sdk/lib/_internal/vm/bin/vmservice_io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -96,25 +96,15 @@ class _DebuggingSession {
bool disableServiceAuthCodes,
bool enableDevTools,
) async {
final dartPath = Uri.parse(Platform.resolvedExecutable);
final dartDir = [
'', // Include leading '/'
...dartPath.pathSegments.sublist(
0,
dartPath.pathSegments.length - 1,
),
].join('/');

final dartDir = File(Platform.resolvedExecutable).parent.path;
final fullSdk = dartDir.endsWith('bin');
final snapshotName = [
dartDir,
fullSdk ? 'snapshots' : 'gen',
'dds.dart.snapshot',
].join('/');
final execName = dartPath.toString();

].join(Platform.pathSeparator);
_process = await Process.start(
execName,
Platform.resolvedExecutable,
[
snapshotName,
'--vm-service-uri=${server!.serverAddress!}',
Expand Down

0 comments on commit 66b9bf5

Please sign in to comment.