dart-lang / dart-lang/webdev

The `sdkRoot` argument to start is not honoured everywhere

Open
#2,767 1 comment 0 reactions 0 assignees View on GitHub
P2 package:frontend_server_client triaged
Dominant language
Dart
Stars
224
Forks
94
Avg merge
4d 3h
Merged PRs (30d)
2

Description

Notice how in `lib/src/frontend_server_client.dart`:
```dart
final _dartAotRuntimePath = p.join(sdkDir, 'bin', 'dartaotruntime');

final _feServerAppJitSnapshotPath =
p.join(sdkDir, 'bin', 'snapshots', 'frontend_server.dart.snapshot');

final _feServerAotSnapshotPath =
p.join(sdkDir, 'bin', 'snapshots', 'frontend_server_aot.dart.snapshot');
```

just use `sdkDir` which is set in `lib/src/shared.dart`
```dart
final sdkDir = p.dirname(p.dirname(Platform.resolvedExecutable));
```
Problem is that `Platform.resolvedExecutable` doesn't work with `dart install`.

However
```dart
static Future start(
...
String? sdkRoot, // Defaults to the current SDK root.
})
```
if only it was used correctly, like:
```dart
String _dartAotRuntimePath(String? sdkRoot) =>
p.join(sdkRoot ?? sdkDir, 'bin', 'dartaotruntime');

String _feServerAppJitSnapshotPath(String? sdkRoot) => p.join(
sdkRoot ?? sdkDir, 'bin', 'snapshots', 'frontend_server.dart.snapshot');

String _feServerAotSnapshotPath(String? sdkRoot) => p.join(
sdkRoot ?? sdkDir, 'bin', 'snapshots', 'frontend_server_aot.dart.snapshot');
```
then it would work with `dart install` as well, if we pass the `sdkRoot` argument.

Contributor guide

Open the contributing guide

Research direction

Start in lib/src/frontend_server_client.dart and inspect FrontendServerClient.start, then compare its sdkRoot handling with sdkDir defined in lib/src/shared.dart. Trace the three frontend-server runtime and snapshot paths and verify that an explicitly supplied SDK root is used, including when invoked through dart install.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.