From dc1916415702fa13403cfb30ad8d97fb95b9956c Mon Sep 17 00:00:00 2001 From: Will Burford Date: Thu, 24 Sep 2026 17:40:34 -0400 Subject: [PATCH 1/2] Resolve Outlines cache from the launcher-provided LM Studio home --- README.md | 6 ++++++ mlx_engine/__init__.py | 21 +++++++-------------- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 67781237..392eeb62 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,12 @@ Download LM Studio from [here](https://lmstudio.ai/download?os=mac)
+## Outlines cache + +LM Studio passes its resolved home in `LMS_LMSTUDIO_HOME`. The engine uses +`/.internal/outlines` for the Outlines cache. An explicit `OUTLINES_CACHE_DIR` +takes precedence. Without either variable, Outlines uses its default cache location. + ## Standalone Demo ### Prerequisites diff --git a/mlx_engine/__init__.py b/mlx_engine/__init__.py index a76c329b..516f2144 100644 --- a/mlx_engine/__init__.py +++ b/mlx_engine/__init__.py @@ -17,6 +17,13 @@ from pathlib import Path import os +# Outlines can open its cache during import, so configure it before loading dependencies. +_lmstudio_home = os.environ.get("LMS_LMSTUDIO_HOME") +if _lmstudio_home and not os.environ.get("OUTLINES_CACHE_DIR"): + os.environ["OUTLINES_CACHE_DIR"] = str( + Path(_lmstudio_home) / ".internal" / "outlines" + ) + from .utils.disable_hf_download import patch_huggingface_hub from .utils.register_models import register_models from .utils.logger import setup_logging @@ -37,17 +44,3 @@ patch_huggingface_hub() register_models() setup_logging() - - -def _set_outlines_cache_dir(cache_dir: Path | str): - """ - Set the cache dir for Outlines. - - Outlines reads the OUTLINES_CACHE_DIR environment variable to - determine where to read/write its cache files - """ - cache_dir = Path(cache_dir).expanduser().resolve() - os.environ["OUTLINES_CACHE_DIR"] = str(cache_dir) - - -_set_outlines_cache_dir(Path("~/.cache/lm-studio/.internal/outlines")) From c571a913f644cfc41ea02dbf65dfe52863ca468c Mon Sep 17 00:00:00 2001 From: Will Burford Date: Fri, 25 Sep 2026 12:50:31 -0400 Subject: [PATCH 2/2] Remove the Outlines cache README addition --- README.md | 6 ------ 1 file changed, 6 deletions(-) diff --git a/README.md b/README.md index 392eeb62..67781237 100644 --- a/README.md +++ b/README.md @@ -26,12 +26,6 @@ Download LM Studio from [here](https://lmstudio.ai/download?os=mac)
-## Outlines cache - -LM Studio passes its resolved home in `LMS_LMSTUDIO_HOME`. The engine uses -`/.internal/outlines` for the Outlines cache. An explicit `OUTLINES_CACHE_DIR` -takes precedence. Without either variable, Outlines uses its default cache location. - ## Standalone Demo ### Prerequisites