Skip to content

Commit 5ac159d

Browse files
authored
fix(cli): Always use Flutter SDK (#610)
Until dart-lang/pub#3563 is resolved, always force the use of the Flutter SDK's `dart` command.
1 parent 96abcbf commit 5ac159d

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

apps/cli/lib/pub/pub_action.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ Future<void> runPub({
2727
exe ??= Sdk.current.dart;
2828
final process = await processManager.start(
2929
<String>[exe, 'pub', action.name],
30+
environment: {
31+
if (Sdk.current.flutterSdkRoot case final flutterSdkRoot?)
32+
'FLUTTER_ROOT': flutterSdkRoot,
33+
},
3034
workingDirectory: workingDirectory,
3135
);
3236
// Must be sync so that completer only completes once before `finally` block

apps/cli/test/pub/pub_action_test.dart

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,49 @@ dependencies:
8383
),
8484
);
8585
});
86+
87+
// TODO(dnys1): Should we allow direct dependencies on Flutter?
88+
test('works when depending on flutter', () async {
89+
tempDir.childFile('pubspec.yaml').writeAsStringSync('''
90+
name: test_1234
91+
92+
environment:
93+
sdk: ^$minSupportedDartSdk
94+
95+
dependencies:
96+
flutter:
97+
sdk: flutter
98+
''');
99+
await expectLater(
100+
runPub(
101+
exe: exe,
102+
action: action,
103+
workingDirectory: tempDir.path,
104+
),
105+
completes,
106+
);
107+
});
108+
109+
test('works with flutter environment constraint', () async {
110+
tempDir.childFile('pubspec.yaml').writeAsStringSync('''
111+
name: test_1234
112+
113+
environment:
114+
sdk: ^$minSupportedDartSdk
115+
flutter: ">=3.19.0"
116+
117+
dependencies:
118+
path: any
119+
''');
120+
await expectLater(
121+
runPub(
122+
exe: exe,
123+
action: action,
124+
workingDirectory: tempDir.path,
125+
),
126+
completes,
127+
);
128+
});
86129
});
87130
}
88131
});

0 commit comments

Comments
 (0)