Skip to content

fix: seed VSSCRIPT_PATH from Windows registry#1244

Open
frankie1024 wants to merge 2 commits into
rust-av:masterfrom
frankie1024:codex/fix-vsscript-api-windows
Open

fix: seed VSSCRIPT_PATH from Windows registry#1244
frankie1024 wants to merge 2 commits into
rust-av:masterfrom
frankie1024:codex/fix-vsscript-api-windows

Conversation

@frankie1024
Copy link
Copy Markdown

Summary

On Windows, Av1an currently relies on one of these being true before VSScript can be loaded:

  • VSSCRIPT_PATH is already set
  • vapoursynth.exe is available on PATH

That misses a common installation state where VapourSynth is installed correctly, the VSScriptDLL registry value exists, but neither of the two discovery paths above is available to Av1an yet. In that case startup can fail with VSScript API not available.

This change adds a Windows-only fallback at process startup:

  • if VSSCRIPT_PATH is missing or empty, read VSScriptDLL from HKCU\\SOFTWARE\\VapourSynth and HKLM\\SOFTWARE\\VapourSynth
  • if the referenced DLL exists, seed VSSCRIPT_PATH before Av1an touches the VapourSynth bindings

Why here

The existing vapoursynth Rust crate already honors VSSCRIPT_PATH; the missing piece is that Av1an does not currently populate it from the standard Windows VapourSynth installation metadata.

Verification

Locally verified on Windows by:

  1. Removing VSSCRIPT_PATH from the process environment
  2. Removing the VapourSynth/Python entries from PATH
  3. Running av1an --version

Before this patch, startup panicked with VSScript API not available.
After this patch, Av1an starts normally and detects VapourSynth through the registry-backed fallback.

I also ran cargo build -p av1an successfully.

Note: cargo test -p av1an still has pre-existing Windows vpy path escaping failures on master (for example encode_test_vpy_input), and this patch does not touch that area.

On Windows, Av1an currently depends on either VSSCRIPT_PATH or the vapoursynth CLI being discoverable before VSScript can be loaded. Standard installations already record the VSScript DLL path in the VapourSynth registry key, so read that value at startup and use it as a fallback when the environment variable is missing or empty.
Comment thread av1an/src/main.rs
@FreezyLemon
Copy link
Copy Markdown
Contributor

Looks sensible, but I wonder if this shouldn't be done in the vapoursynth crate...

@frankie1024
Copy link
Copy Markdown
Author

Thanks for the review.

This PR is mainly to address the Windows case where VapourSynth is installed but VSSCRIPT_PATH is not set, which causes Av1an to fail finding VSScript.

The current change adds a fallback in Av1an so users can run without manually exporting the env var. I’ll add a short safety comment for the unsafe block.

Re the design question: I agree it may be cleaner for this to live in the vapoursynth crate long-term. I kept it in Av1an here as the smallest fix for the immediate user-facing issue, but I’m happy to move it upstream if that’s preferred.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants