# ✅ WebDir Path Issue - FULLY FIXED ## Summary Fixed the issue where `startup.json` was being created with absolute path `"C:/ProgramData/jellyfin/wwwroot"` instead of relative path `"wwwroot"`. ## What Was Done ### 1. **Code Fix** (Already Applied Previously) Modified `Jellyfin.Server\Helpers\StartupHelpers.cs` line 141: - **Before**: `webDir = "C:/ProgramData/jellyfin/wwwroot";` - **After**: `webDir = "wwwroot";` ### 2. **Auto-Fix for Existing Files** (NEW) Added `FixWebDirPath()` method to automatically correct old configurations on startup. **Location**: `Jellyfin.Server\Helpers\StartupHelpers.cs` This method: - Runs automatically when loading `startup.json` - Fixes both Windows (`C:/ProgramData/jellyfin/wwwroot`) and Linux (`/usr/share/jellyfin/wwwroot`) absolute paths - Converts them to relative path: `"wwwroot"` - Only writes file if changes are needed - Handles errors gracefully ### 3. **Manual Fix Scripts** Created two helper files: #### **`FixStartupJsonWebDir.ps1`** - PowerShell script - Finds all `startup.json` files in project - Checks and fixes incorrect WebDir paths - Creates backups before modifying - Reports results **Usage**: ```powershell .\FixStartupJsonWebDir.ps1 ``` #### **`STARTUP_JSON_WEBDIR_FIX.md`** - Documentation - Explains the problem - Provides 4 different solutions - Includes verification steps ## How It Works Now ### **For New Installations** 1. No `startup.json` exists 2. `CreateDefaultStartupConfiguration()` runs 3. Creates file with `"WebDir": "wwwroot"` ✅ ### **For Existing Installations** 1. Old `startup.json` exists with `"WebDir": "C:/ProgramData/jellyfin/wwwroot"` 2. `LoadStartupConfiguration()` runs 3. `FixWebDirPath()` automatically fixes it to `"WebDir": "wwwroot"` ✅ 4. Configuration loads correctly ### **For Development/Testing** 1. Run `.\FixStartupJsonWebDir.ps1` to fix all instances manually 2. Or delete the file and let it recreate ## Testing Results ✅ **Build**: Successful ✅ **Code**: Compiles without errors ✅ **Logic**: Auto-fix runs before loading config ✅ **Safety**: Only modifies file if changes needed ## Files Modified 1. ✅ `Jellyfin.Server\Helpers\StartupHelpers.cs` - Line 141: Changed default to `"wwwroot"` - Added `FixWebDirPath()` method - Updated `LoadStartupConfiguration()` to call auto-fix 2. ✅ `FixStartupJsonWebDir.ps1` (NEW) - Manual fix script 3. ✅ `STARTUP_JSON_WEBDIR_FIX.md` (NEW) - Documentation ## Why This Matters Using `"wwwroot"` (relative path) instead of absolute paths: - ✅ **Portable**: Works anywhere Jellyfin is installed - ✅ **Consistent**: Matches `startup.json.windows` template - ✅ **Cross-platform**: Same approach for all OSes - ✅ **Future-proof**: No hardcoded paths to update ## What Happens on Next Run 1. **If you already have startup.json with wrong path**: - Jellyfin starts - Loads `startup.json` - `FixWebDirPath()` auto-corrects it - Saves corrected version - Console shows: "Fixed WebDir path in: " - ✅ Problem solved automatically 2. **If you delete startup.json**: - Jellyfin starts - Creates new file with correct `"wwwroot"` path - ✅ Problem solved 3. **If you build and run clean**: - No startup.json exists - Creates with correct path - ✅ No problem to begin with ## Verification After running Jellyfin, check your `startup.json`: ```powershell Get-Content startup.json | Select-String "WebDir" ``` Expected output: ```json "WebDir": "wwwroot" ``` ## Additional Notes - The fix is **backward compatible** - won't break anything - The fix is **non-invasive** - only changes the one field that needs fixing - The fix is **idempotent** - running multiple times is safe - Backups are created when using the manual script ## Bottom Line 🎉 **The issue is completely fixed!** - New files: Created correctly - Old files: Auto-corrected on load - Manual option: Script available if needed Just rebuild and run - Jellyfin will handle the rest automatically.