# Startup.json Configuration Fix - Marker Conflict Resolution

**Date:** 2026-02-26  
**Status:** ✅ Fixed  
**Issue:** DataDir and ConfigDir pointing to same location

---

## Root Cause

### The Problem

**File:** `E:\Program Files\jellyfin-win\startup.json`

**Problematic Configuration:**
```json
{
  "Paths": {
    "DataDir": "C:/ProgramData/jellyfin",     ← SAME
    "ConfigDir": "C:/ProgramData/jellyfin",   ← SAME
    "CacheDir": "C:/ProgramData/jellyfin/cache",
    "LogDir": "C:/ProgramData/jellyfin/log"
  }
}
```

**Why This Failed:**
1. DataDir creates `.jellyfin-data` marker in `C:/ProgramData/jellyfin`
2. ConfigDir creates `.jellyfin-config` marker in `C:/ProgramData/jellyfin`
3. Sanity check finds both markers in same directory
4. **Error:** "Expected to find only .jellyfin-data but found marker for .jellyfin-config"

---

## The Fix

### Updated Configuration ✅

**File:** `E:\Program Files\jellyfin-win\startup.json`

**New Configuration:**
```json
{
  "_comment": "Jellyfin Startup Configuration - Windows with separate directories",
  "_note": "Using separate subdirectories to avoid marker conflicts",
  "_priority": "Command-line args > Environment variables > This file > Built-in defaults",
  "Paths": {
    "DataDir": "C:/ProgramData/jellyfin/data",      ← Separate
    "ConfigDir": "C:/ProgramData/jellyfin/config",  ← Separate
    "CacheDir": "C:/ProgramData/jellyfin/cache",
    "LogDir": "C:/ProgramData/jellyfin/log",
    "TempDir": "C:/Users/wjones/AppData/Local/Temp/jellyfin",
    "WebDir": "C:/ProgramData/jellyfin/web"
  }
}
```

**Changes:**
- ✅ DataDir: `C:/ProgramData/jellyfin` → `C:/ProgramData/jellyfin/data`
- ✅ ConfigDir: `C:/ProgramData/jellyfin` → `C:/ProgramData/jellyfin/config`
- ✅ Each directory gets its own marker file
- ✅ No conflicts!

---

## What Was Done

### Step 1: Backed Up Original ✅

**Backup Location:** `E:\Program Files\jellyfin-win\startup.json.backup`

```powershell
Copy-Item "E:\Program Files\jellyfin-win\startup.json" "E:\Program Files\jellyfin-win\startup.json.backup"
```

### Step 2: Updated Configuration ✅

**Updated Paths:**
- DataDir → separate subdirectory
- ConfigDir → separate subdirectory

### Step 3: Cleaned Up Old Markers ✅

**Removed:**
- `C:\ProgramData\jellyfin\.jellyfin-config`
- `C:\ProgramData\jellyfin\.jellyfin-data`

---

## New Directory Structure

### After Fix

```
C:\ProgramData\jellyfin\
├── data\                       ← Database, media library data
│   └── .jellyfin-data          ← Data marker
├── config\                     ← Configuration files
│   └── .jellyfin-config        ← Config marker
├── cache\                      ← Cache files
│   └── .jellyfin-cache         ← Cache marker
├── log\                        ← Log files
│   └── .jellyfin-log           ← Log marker
└── web\                        ← Web UI files
```

**Each directory has its own marker - no conflicts!** ✅

---

## Why startup.json Exists

### Configuration Loading Order

**Priority (highest to lowest):**
1. **Command-line arguments** - e.g., `--datadir "C:\custom\path"`
2. **Environment variables** - e.g., `JELLYFIN_DATA_DIR=C:\custom`
3. **startup.json** - Configuration file ← This was the issue
4. **Built-in defaults** - Hardcoded in application

### Location Priority

Jellyfin searches for `startup.json` in:
1. Current directory (where jellyfin.dll is located)
2. Program Files installation directory
3. AppData directories

**In your case:** Found at `E:\Program Files\jellyfin-win\startup.json`

---

## Verification

### Check Current Configuration

```powershell
# View current startup.json
Get-Content "E:\Program Files\jellyfin-win\startup.json" | ConvertFrom-Json | Format-List

# Should show:
# DataDir   : C:/ProgramData/jellyfin/data
# ConfigDir : C:/ProgramData/jellyfin/config
```

### Check for Markers

```powershell
# Root directory should have NO markers
Get-ChildItem "C:\ProgramData\jellyfin" -Filter ".jellyfin-*" | Select-Object Name

# Subdirectories should have markers
Get-ChildItem "C:\ProgramData\jellyfin" -Filter ".jellyfin-*" -Recurse | Select-Object FullName
```

**Expected:**
```
C:\ProgramData\jellyfin\data\.jellyfin-data
C:\ProgramData\jellyfin\config\.jellyfin-config
C:\ProgramData\jellyfin\cache\.jellyfin-cache
C:\ProgramData\jellyfin\log\.jellyfin-log
```

---

## Start Jellyfin

### Now You Can Start

```bash
cd E:\Projects\pgsql-jellyfin\lib\Release\net11.0
dotnet jellyfin.dll
```

**Expected Output:**
```
[INF] Loaded startup configuration from: E:\Program Files\jellyfin-win\startup.json
[INF] Data directory: C:\ProgramData\jellyfin\data
[INF] Config directory: C:\ProgramData\jellyfin\config
[INF] Cache directory: C:\ProgramData\jellyfin\cache
[INF] Log directory: C:\ProgramData\jellyfin\log
[INF] Jellyfin version: 11.0.0-PostgreSQL PREVIEW
```

---

## Alternative: Override Configuration

### Option 1: Command-Line Override

Don't want to modify startup.json? Use command-line args:

```bash
dotnet jellyfin.dll \
  --datadir "C:/ProgramData/jellyfin/data" \
  --configdir "C:/ProgramData/jellyfin/config"
```

### Option 2: Delete startup.json

Remove the file and use built-in defaults:

```powershell
Remove-Item "E:\Program Files\jellyfin-win\startup.json"
```

Built-in defaults will create proper structure automatically.

### Option 3: Use Project-Local Configuration

Create startup.json in your build directory:

```powershell
cd E:\Projects\pgsql-jellyfin\lib\Release\net11.0

$config = @"
{
  "Paths": {
    "DataDir": "E:/Projects/pgsql-jellyfin/dev-data/data",
    "ConfigDir": "E:/Projects/pgsql-jellyfin/dev-data/config",
    "CacheDir": "E:/Projects/pgsql-jellyfin/dev-data/cache",
    "LogDir": "E:/Projects/pgsql-jellyfin/dev-data/log"
  }
}
"@

Set-Content -Path "startup.json" -Value $config
```

---

## Common Mistakes

### ❌ Don't Do This

```json
{
  "Paths": {
    "DataDir": "C:/ProgramData/jellyfin",     ← BAD
    "ConfigDir": "C:/ProgramData/jellyfin"    ← BAD
  }
}
```

**Problem:** Same directory for both!

### ❌ Don't Do This Either

```json
{
  "Paths": {
    "DataDir": "C:/jellyfin",
    "ConfigDir": "C:/jellyfin/config",        ← BAD
    "CacheDir": "C:/jellyfin/config/cache"    ← BAD (nested in config)
  }
}
```

**Problem:** Nested directories can cause conflicts

### ✅ Do This

```json
{
  "Paths": {
    "DataDir": "C:/ProgramData/jellyfin/data",
    "ConfigDir": "C:/ProgramData/jellyfin/config",
    "CacheDir": "C:/ProgramData/jellyfin/cache",
    "LogDir": "C:/ProgramData/jellyfin/log"
  }
}
```

**Good:** Each path is a separate subdirectory

---

## Rollback

### If Something Goes Wrong

**Restore original configuration:**

```powershell
Copy-Item "E:\Program Files\jellyfin-win\startup.json.backup" "E:\Program Files\jellyfin-win\startup.json" -Force
```

**Or delete startup.json entirely:**

```powershell
Remove-Item "E:\Program Files\jellyfin-win\startup.json"
```

Then use command-line args to specify paths.

---

## For Future Reference

### Creating Correct startup.json

**Template:**

```json
{
  "_comment": "Jellyfin Startup Configuration",
  "_note": "Use separate subdirectories for each path type",
  "Paths": {
    "DataDir": "C:/ProgramData/jellyfin/data",
    "ConfigDir": "C:/ProgramData/jellyfin/config",
    "CacheDir": "C:/ProgramData/jellyfin/cache",
    "LogDir": "C:/ProgramData/jellyfin/log",
    "TempDir": "C:/Users/USERNAME/AppData/Local/Temp/jellyfin",
    "WebDir": "C:/ProgramData/jellyfin/web"
  },
  "Database": {
    "DatabaseType": "Jellyfin-PostgreSQL",
    "CustomProviderOptions": {
      "Options": [
        { "Key": "host", "Value": "localhost" },
        { "Key": "port", "Value": "5432" },
        { "Key": "database", "Value": "jellyfin" },
        { "Key": "username", "Value": "jellyfin" },
        { "Key": "password", "Value": "your-password" }
      ]
    }
  }
}
```

---

## Summary

**Problem:** startup.json had DataDir and ConfigDir pointing to same location  
**Cause:** Previous installation configuration  
**Fix:** Updated paths to use separate subdirectories  
**Result:** No more marker conflicts  

**Files Changed:**
1. `E:\Program Files\jellyfin-win\startup.json` - Updated paths
2. Backup created at `startup.json.backup`
3. Cleaned up old markers from `C:\ProgramData\jellyfin\`

**Status:** ✅ Ready to start Jellyfin!

**Command:**
```bash
cd E:\Projects\pgsql-jellyfin\lib\Release\net11.0
dotnet jellyfin.dll
```

---

**Lesson Learned:** Always use separate subdirectories for different path types to avoid marker conflicts! ✅
