configureCacheDir function
Seed the HuggingFace cache environment for sandboxed platforms.
On iOS (and Android), the default ~/.cache/huggingface/hub path is outside
the app sandbox and writes fail with Operation not permitted (os error 1).
Call this once at startup — before any load_gguf_model or
download_model — with the app's writable data directory.
Dart usage
import 'package:path_provider/path_provider.dart';
final dir = await getApplicationSupportDirectory();
configureCacheDir(appDataDir: dir.path);
Internally this:
- Creates
<app_data_dir>/huggingface/hub/if it doesn't exist. - Sets the
HF_HOMEandHF_HUB_CACHEenvironment variables. - Seeds
mistralrs_core::GLOBAL_HF_CACHEso the model loader never falls back toCache::default().
Implementation
void configureCacheDir({required String appDataDir}) =>
RustLib.instance.api.crateApiConfigureCacheDir(appDataDir: appDataDir);