Skip to content

on 0.13.0, rust-analyzer reports "template not found" error in workspace with multiple crates #394

@strickczq

Description

@strickczq

I’m encountering an issue with #[derive(Template)] in a Rust workspace using askama 0.13.0.

Both cargo check and build work fine, but rust-analyzer reports "template not found" errors depending on which crate it analyzes first.

This issue does not occur with askama 0.12.1.

Problem

In a workspace with two crates (a and b), each using #[derive(Template)] for their own templates folder:

  • If rust-analyzer starts with crates/a, a works, but b gets:
Image
  • If rust-analyzer starts with crates/b, b works, but a gets:
Image

It seems RA uses the first-analyzed crate’s templates folder for all crates.

Steps to Reproduce

See minimal example:

https://github.com/strickczq/askama-ra-error-in-workspace

  1. Clone and open the project in VS Code with rust-analyzer freshly.
  2. (crates/a/lib.rs) Open this file, RA works.
  3. (crates/b/lib.rs) Then open this file, RA reports error.
  4. (crates/b/lib.rs) Run rust-analyzer: Restart Server, RA works now.
  5. (crates/a/lib.rs) Reopen this file, RA reports error.

Expected

rust-analyzer finds each crate’s templates in its own templates folder.

Actual

rust-analyzer uses the first-analyzed crate’s templates folder, causing errors for others.

Environment

  • rust: 1.85.1 (4eb161250 2025-03-15)
  • rust-analyzer: 0.3.2370-standalone (588948f267 2025-04-06)
  • askama: 0.13.0 (issue present; 0.12.1 works fine)
  • OS: macOS 15.3.2 (24D81)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions