Flutter test - FileSystemException: Creation failed, path = '/' (OS Error: Read-only file system, errno = 30) - MacOS

92 views Asked by At

In running flutter test on MacOS I am getting this error: FileSystemException: Creation failed, path = '/mock' (OS Error: Read-only file system, errno = 30)

Note that it is working fine on Windows and Ubuntu.

I am using the path_provider package, following this example here: https://github.com/flutter/packages/blob/main/packages/path_provider/path_provider/test/path_provider_test.dart

and overriding the values:

import "package:flutter_test/flutter_test.dart";
import "package:path_provider_platform_interface/path_provider_platform_interface.dart"
    show PathProviderPlatform, StorageDirectory;
import "package:plugin_platform_interface/plugin_platform_interface.dart";


const String kTemporaryPath = "/mock/temporaryPath";

class MockPathProviderPlatform extends Mock
    with MockPlatformInterfaceMixin
    implements PathProviderPlatform {
  @override
  Future<String> getTemporaryPath() async {
    return kTemporaryPath;
  }

I tried to change permissions in the current directory with sudo chmod -R 777 <current-directory but it didn't help.

1

There are 1 answers

0
Raphael Pinel On

The fix was to remove the leading / in the kTemporaryPath

const String kTemporaryPath = "mock/temporaryPath";

Also, good idea to add the mock directory (or however you named it) directory in .gitignore