Skip to content

πŸ“„ Improve clerk_auth example and README – DefaultPersistor fails silently on mobile due to Directory.current.Β #175

Open
@Turskyi

Description

@Turskyi

Steps to reproduce

  1. Clone the clerk-sdk-flutter repo
  2. Open the packages/clerk_auth/example/ directory
  3. Replace with a valid key in main.dart
  4. Run the example on an iOS simulator or device (not on desktop)
  5. Observe the crash when DefaultPersistor.create(storageDirectory: Directory.current) is called

Expected results

β€’	The example should run without throwing any unhandled exceptions
β€’	If Directory.current is not suitable for the platform, a helpful error should be shown
β€’	The README should warn developers that Directory.current does not work on iOS and suggest alternatives like path_provider

Actual results

β€’	The app is running, but throws:
FileSystemException: Cannot open file, path = '//clerk_sdk.json' (OS Error: Read-only file system, errno = 30)
β€’	No prior indication in the README that this code is not mobile-safe
β€’	The example misleads developers into thinking the setup works cross-platform

Code sample

From clerk_auth/example/main.dart:

Code sample
final auth = Auth(
  config: const AuthConfig(
    publishableKey: '<YOUR-PUBLISHABLE-KEY>',
  ),
  persistor: await DefaultPersistor.create(
    storageDirectory: Directory.current, // ← problematic on iOS
  ),
);

Screenshots or Video

No response

Logs

Logs
[ERROR:flutter/runtime/dart_vm_initializer.cc(40)] Unhandled Exception: FileSystemException: Cannot open file, path = '//clerk_sdk.json' (OS Error: Read-only file system, errno = 30)

Flutter Doctor output

Doctor output
[βœ“] Flutter (Channel stable, 3.29.2, on macOS 15.4.1 24E263 darwin-arm64, locale en-CA) [1,546ms]
    β€’ Flutter version 3.29.2 on channel stable at /Users/dmytro/flutter
    β€’ Upstream repository https://github.com/flutter/flutter.git
    β€’ Framework revision c236373904 (7 weeks ago), 2025-03-13 16:17:06 -0400
    β€’ Engine revision 18b71d647a
    β€’ Dart version 3.7.2
    β€’ DevTools version 2.42.3

[βœ“] Android toolchain - develop for Android devices (Android SDK version 35.0.0) [2.5s]
    β€’ Android SDK at /Users/dmytro/Library/Android/sdk
    β€’ Platform android-35, build-tools 35.0.0
    β€’ ANDROID_SDK_ROOT = /Users/dmytro/Library/Android/sdk
    β€’ Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    β€’ Java version OpenJDK Runtime Environment (build 21.0.6+-13355223-b631.42)
    β€’ All Android licenses accepted.

[βœ“] Xcode - develop for iOS and macOS (Xcode 16.3) [1,348ms]
    β€’ Xcode at /Applications/Xcode.app/Contents/Developer
    β€’ Build 16E140
    β€’ CocoaPods version 1.16.2

[βœ“] Chrome - develop for the web [92ms]
    β€’ Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[βœ“] Android Studio (version 2024.3) [92ms]
    β€’ Android Studio at /Applications/Android Studio.app/Contents
    β€’ Flutter plugin can be installed from:
      πŸ”¨ https://plugins.jetbrains.com/plugin/9212-flutter
    β€’ Dart plugin can be installed from:
      πŸ”¨ https://plugins.jetbrains.com/plugin/6351-dart
    β€’ Java version OpenJDK Runtime Environment (build 21.0.6+-13355223-b631.42)

[βœ“] IntelliJ IDEA Community Edition (version 2025.1) [91ms]
    β€’ IntelliJ at /Applications/IntelliJ IDEA CE.app
    β€’ Flutter plugin version 85.2.4
    β€’ Dart plugin version 251.25267.1

[βœ“] VS Code (version 1.99.3) [9ms]
    β€’ VS Code at /Applications/Visual Studio Code.app/Contents
    β€’ Flutter extension version 3.108.0

[βœ“] Connected device (5 available) [6.4s]
    β€’ iPad (wireless) (mobile) β€’ 00008020-001E6D690168402E            β€’ ios            β€’ iOS 18.3.2 22D82
    β€’ iPhone 16 Pro Max (mobile)                     β€’ DB8962E0-74F5-4EF5-88B8-991A0E9AB40E β€’ ios            β€’
      com.apple.CoreSimulator.SimRuntime.iOS-18-4 (simulator)
    β€’ macOS (desktop)                                β€’ macos                                β€’ darwin-arm64   β€’ macOS 15.4.1 24E263
      darwin-arm64
    β€’ Mac Designed for iPad (desktop)                β€’ mac-designed-for-ipad                β€’ darwin         β€’ macOS 15.4.1 24E263
      darwin-arm64
    β€’ Chrome (web)                                   β€’ chrome                               β€’ web-javascript β€’ Google Chrome
      135.0.7049.115

[βœ“] Network resources [370ms]
    β€’ All expected network resources are available.

β€’ No issues found!

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions