diff --git a/05-troubleshooting/obs-stale-script-paths-after-windows-profile-rename.md b/05-troubleshooting/obs-stale-script-paths-after-windows-profile-rename.md new file mode 100644 index 0000000..5d0ee41 --- /dev/null +++ b/05-troubleshooting/obs-stale-script-paths-after-windows-profile-rename.md @@ -0,0 +1,129 @@ +--- +title: "OBS Studio — \"Error opening file: (null)\" After Windows Profile Rename" +domain: troubleshooting +category: streaming +tags: [obs, streaming, windows, lua, profile-migration] +status: published +created: 2026-05-14 +updated: 2026-05-14 +--- + +# OBS Studio — "Error opening file: (null)" After Windows Profile Rename + +## Symptom + +Loading a scene collection in OBS Studio triggers a popup like: + +``` +[.lua] Error opening file: (null) +``` + +The `(null)` is the giveaway: OBS resolved the registered script path to nothing — the file doesn't exist where the scene collection says it does. Most commonly this happens after a Windows profile was renamed or migrated and `C:\Users\\...` paths were not updated. + +## Why it happens + +OBS stores per-scene-collection Lua/Python script registrations inside the scene collection JSON at: + +``` +%APPDATA%\obs-studio\basic\scenes\.json +``` + +Each entry under `modules.scripts-tool[]` is an absolute Windows path. Renaming the Windows profile does not rewrite these — the JSON keeps pointing at the old `C:\Users\\...` location, and OBS surfaces the resolution failure as a `(null)` popup on collection load. + +## Diagnose + +From WSL (or any shell with access to `%APPDATA%`): + +```bash +OBS_DIR="/mnt/c/Users//AppData/Roaming/obs-studio" + +# 1. List scene collections +ls "$OBS_DIR/basic/scenes/" + +# 2. Find collections referencing the missing script +grep -l -i "" "$OBS_DIR/basic/scenes/"*.json + +# 3. Dump the scripts-tool paths from each suspect collection +python3 -c " +import json, sys +d = json.load(open(sys.argv[1])) +for s in d.get('modules', {}).get('scripts-tool', []): + print(s.get('path')) +" "$OBS_DIR/basic/scenes/.json" +``` + +If a printed path contains `C:/Users//...` and the file doesn't exist on disk, you've found it. + +## Fix + +> [!warning] Close OBS first +> OBS rewrites the scene collection JSON when it exits. Any edit made while OBS is running will be overwritten. Confirm with `tasklist.exe | grep obs64` (WSL) or Task Manager. + +### 1. Make the missing script reachable + +Either: + +- **Re-extract / restore the script** to a path under the new profile (recommended — gives you a clean canonical home), or +- **Leave it in the rescue/migration folder** and point OBS there (fragile if the rescue folder is later deleted). + +### 2. Back up the scene collection JSON + +```bash +SCENES="/mnt/c/Users//AppData/Roaming/obs-studio/basic/scenes" +STAMP="$(date +%Y%m%d-%H%M%S)" +cp -p "$SCENES/.json" "$SCENES/.json.$STAMP.bak" +``` + +### 3. Rewrite the paths atomically + +Edit the JSON in place by parsing it, replacing the matched path strings, and writing through a temp file (so a crash mid-write can't corrupt the collection): + +```bash +python3 <<'PY' +import json, os +scenes = "/mnt/c/Users//AppData/Roaming/obs-studio/basic/scenes" +mapping = { + "C:/Users//Pictures/.../