Skip to content

savagelysubtle/lmstudio-home-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LM Studio Home Manager

License: MIT Rust

A utility to manage LM Studio's home directory location via environment variables and filesystem junctions/symlinks.

The Problem

LM Studio is a popular desktop application for running local LLMs. Unlike most developer tools, it hardcodes its data directory location and doesn't respect environment variables for configuration.

Tool Configurable? Environment Variable
Ollama ✅ Yes OLLAMA_MODELS
Cargo (Rust) ✅ Yes CARGO_HOME
pip ✅ Yes PIP_CACHE_DIR
uv ✅ Yes UV_CACHE_DIR
LM Studio No None

Why This Matters

  1. Disk Space Management: LLM models are massive (7-70GB+ each). Users with small C: drives (SSDs) need to store them elsewhere.
  2. Multi-Drive Setups: Many users have fast SSD (C:) for OS/apps and large HDD (D:, E:) for data.
  3. Session Cache Bloat: LM Studio's .session_cache folder can grow to 100-300GB without user awareness.

Related GitHub Issue: lmstudio-ai/lmstudio-bug-tracker#230

Solution

This tool provides a workaround by:

  1. Managing filesystem junctions (Windows) or symlinks (Unix) to redirect LM Studio's data directory
  2. Monitoring and cleaning up session cache that can grow very large
  3. Providing a launcher that ensures proper setup before starting LM Studio

Installation

From Source (Recommended)

# Clone the repository
git clone https://github.com/savagelysubtle/lmstudio-home-manager.git
cd lmstudio-home-manager

# Build the release binary
cargo build --release

# The binary is at: target/release/lmstudio-home-manager.exe (Windows)
# Or: target/release/lmstudio-home-manager (Linux/macOS)

Add to PATH

# Windows (PowerShell) - Add to user PATH
$env:PATH += ";D:\Coding\LmStudioDev\target\release"

# To make permanent, add to your PowerShell profile:
notepad $PROFILE
# Add: $env:PATH += ";D:\path\to\lmstudio-home-manager\target\release"

Quick Start

# 1. Set your preferred LM Studio data location
setx LM_STUDIO_HOME "D:\ProgramData\LM Studio"

# 2. Run setup to create the junction
lmstudio-home-manager setup

# 3. Check status
lmstudio-home-manager status

# 4. Launch LM Studio (ensures junction is valid first)
lmstudio-home-manager launch

Usage

Setup Junction/Symlink

# Use the path from config/env var
lmstudio-home-manager setup

# Or specify a custom target
lmstudio-home-manager setup --target "E:\AI\LMStudio"

Check Status

lmstudio-home-manager status

Output shows:

  • Junction/symlink status and target
  • LM Studio installation location
  • Disk space usage by category (models, cache, etc.)
  • Whether LM Studio is running

Launch LM Studio

# Launch and return immediately
lmstudio-home-manager launch

# Launch and wait for exit
lmstudio-home-manager launch --wait

Cache Management

# Check cache size
lmstudio-home-manager cache-status

# Preview what would be cleaned (dry run)
lmstudio-home-manager cleanup-cache --dry-run

# Clean files older than 7 days (default)
lmstudio-home-manager cleanup-cache --force

# Clean files older than 3 days
lmstudio-home-manager cleanup-cache --force --older-than-days 3

Configuration

# View current config
lmstudio-home-manager config --show

# Edit config file
lmstudio-home-manager config --edit

Uninstall

# Remove junction only (preserves data)
lmstudio-home-manager uninstall

# Remove junction AND all data (DANGEROUS!)
lmstudio-home-manager uninstall --remove-data

Configuration

Configuration is stored in:

  • Windows: %APPDATA%\lmstudio-home-manager\lmstudio-home-manager\config.toml
  • Linux/macOS: ~/.config/lmstudio-home-manager/config.toml

Example Config

[paths]
# Main LM Studio data directory (where data will actually be stored)
home = "D:\\ProgramData\\LM Studio"

# Optional: Override path for models only
# models = "D:\\ProgramData\\LM Studio\\models"

# Optional: Override path for session cache only
# cache = "D:\\ProgramData\\LM Studio\\cache"

[cleanup]
# Maximum allowed size of session cache in GB
session_cache_max_gb = 50

# Automatically clean up when threshold exceeded
auto_cleanup = false

# Days after which old cache files can be deleted
cache_retention_days = 7

[lmstudio]
# Custom path to LM Studio executable (auto-detected if not set)
# executable_path = "C:\\Users\\Me\\AppData\\Local\\Programs\\LM Studio\\LM Studio.exe"

[updates]
# Check for LM Studio version changes
check_lmstudio_version = true

# Automatically update junctions after LM Studio updates
auto_update_junctions = true

Environment Variables

Variable Description
LM_STUDIO_HOME Main data directory (overrides config)
LM_STUDIO_MODELS Models directory (optional override)
LM_STUDIO_CACHE Session cache directory (optional override)

How It Works

Windows (Junctions)

On Windows, this tool creates directory junctions (similar to symlinks but for directories). These are transparent to applications:

~\.lmstudio\  (junction) → D:\ProgramData\LM Studio\

LM Studio thinks it's writing to ~\.lmstudio\, but the data actually goes to your chosen location.

macOS/Linux (Symlinks)

On Unix systems, standard symbolic links are used:

~/.lmstudio  (symlink) → /data/lm-studio/

Data Migration

When you run setup, if LM Studio data already exists in the default location, the tool will:

  1. Check if target has data - If yes, merge (skip existing files)
  2. Copy data to the new location
  3. Remove original directory
  4. Create junction/symlink pointing to the new location

This ensures no data loss during migration.

Troubleshooting

"LM Studio not found"

  1. Install LM Studio from https://lmstudio.ai/
  2. Or set the path manually in config:
    [lmstudio]
    executable_path = "C:\\path\\to\\LM Studio.exe"

"Path exists but is not a junction"

Run setup to migrate existing data and create the junction:

lmstudio-home-manager setup

"Failed to create junction"

On older Windows versions, you may need to run as Administrator. Windows 10+ should work without elevation.

Cache Growing Too Large

  1. Check current size: lmstudio-home-manager cache-status
  2. Clean old files: lmstudio-home-manager cleanup-cache --force
  3. Enable auto-cleanup in config:
    [cleanup]
    auto_cleanup = true
    session_cache_max_gb = 50

Development

# Run with logging
RUST_LOG=debug cargo run -- status

# Run tests
cargo test

# Build release
cargo build --release

Contributing

Contributions welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Submit a Pull Request

License

MIT License - see LICENSE for details.

Related

About

A utility to manage LM Studio home directory location via environment variables and filesystem junctions/symlinks

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages