Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flutter_tools] handle ERROR_INVALID_FUNCTION when trying to symlink across drives #136424

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/flutter_tools/lib/src/flutter_plugins.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,14 @@ void handleSymlinkException(FileSystemException e, {
: 'You must build from a terminal run as administrator.';
throwToolExit('Building with plugins requires symlink support.\n\n$instructions');
}
// ERROR_INVALID_FUNCTION, trying to link across drives, which is not supported
if (e.osError?.errorCode == 1) {
throwToolExit(
'Creating symlink from $source to $destination failed with '
'ERROR_INVALID_FUNCTION. Try moving your Flutter project to the same '
'drive as your Flutter SDK.',
);
}
}
}

Expand Down
18 changes: 18 additions & 0 deletions packages/flutter_tools/test/general.shard/plugins_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1690,6 +1690,24 @@ flutter:
);
});

testWithoutContext('Symlink failures instruct developers to have their project on the same drive as their SDK', () async {
final Platform platform = FakePlatform(operatingSystem: 'windows');
final FakeOperatingSystemUtils os = FakeOperatingSystemUtils('Microsoft Windows [Version 10.0.14972]');

const FileSystemException e = FileSystemException('', '', OSError('', 1));

expect(
() => handleSymlinkException(
e,
platform: platform,
os: os,
source: pubCachePath,
destination: ephemeralPackagePath,
),
throwsToolExit(message: 'Try moving your Flutter project to the same drive as your Flutter SDK'),
);
});

testWithoutContext('Symlink failures only give instructions for specific errors', () async {
final Platform platform = FakePlatform(operatingSystem: 'windows');
final FakeOperatingSystemUtils os = FakeOperatingSystemUtils('Microsoft Windows [Version 10.0.14393]');
Expand Down