Skip to content

fix: hot-reload throw path contains backslash in windows - #75

Open
moe-moe-pupil wants to merge 1 commit into
voxell-tech:mainfrom
moe-moe-pupil:fix-hotreload-for-windows
Open

fix: hot-reload throw path contains backslash in windows#75
moe-moe-pupil wants to merge 1 commit into
voxell-tech:mainfrom
moe-moe-pupil:fix-hotreload-for-windows

Conversation

@moe-moe-pupil

Copy link
Copy Markdown

Why

im facing an issue for hot-reload in windows, Failed to load asset 'typst\client\in_lobby.typ' with asset loader 'velyst::asset::VelystSourceLoader': path contains backslash
bc in windows, load_context.path().to_string() returns a path string with "\"

  // assets.rs
let path = load_context.path().to_string().replace('\\', "/");
    let source = Source::new(
        FileId::new(RootedPath::new(
            typst::syntax::VirtualRoot::Project,
            VirtualPath::new(&path).map_err(|e| {
                std::io::Error::new(
                    std::io::ErrorKind::InvalidInput,
                    e,
                )
            })?,
        )),
        text,
    );

Testing

i only test it on my windows pc, it works well for me

fix Failed to load asset 'typst\client\in_lobby.typ' with asset loader 'velyst::asset::VelystSourceLoader': path contains backslash
bc in windows, load_context.path().to_string() returns a path string with "\\"
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b3b63c3e-42c3-4d87-b995-426c93892121

📥 Commits

Reviewing files that changed from the base of the PR and between f5823ed and d87dd3a.

📒 Files selected for processing (1)
  • crates/velyst/src/asset.rs

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved asset loading on Windows by consistently handling file paths with backslashes.
    • Fixed potential issues locating files when paths use Windows-style separators.

Walkthrough

The asset loader now converts backslashes in Typst loader paths to forward slashes before constructing the VirtualPath and FileId.

Changes

Asset loader path normalization

Layer / File(s) Summary
Normalize paths before FileId construction
crates/velyst/src/asset.rs
VelystSourceLoader::load replaces backslashes with forward slashes before creating the VirtualPath.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Suggested reviewers: nixonyh

Poem

A bunny hops through paths anew,
Turning backslashes into / too.
Each file ID lands just right,
Windows paths now fit Typst’s sight.
Hop, hop—clean paths in flight!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly matches the Windows hot-reload backslash path fix in the changeset.
Description check ✅ Passed The description is directly related to the Windows asset-path normalization fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nixonyh
nixonyh self-requested a review July 21, 2026 08:11
@nixonyh

nixonyh commented Jul 21, 2026

Copy link
Copy Markdown
Member

Oo, I think we had similar issue last time with voxell-tech/motiongfx#38

May be worth referencing.

@moe-moe-pupil

Copy link
Copy Markdown
Author

Oo, I think we had similar issue last time with voxell-tech/motiongfx#38

May be worth referencing.

thanks for quick reply, but i think it's different, in my case, the load_context.path().to_string() returns "typst\\client\\in_lobby.typ", feels like it's not a string concat issue, the issue u mentioned is bc it hardcoded a ".\\" path in it before, im not familiar with how bevy_assets works, i can be wrong, feel free to correct me xD.

@nixonyh

nixonyh commented Jul 22, 2026

Copy link
Copy Markdown
Member

I see, I'll take a look in testing this to make sure it works in other os-es too. Thanks for this PR!

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