Skip to content

fix(bazel): replace askama templates with include_str! in memories#11778

Open
rupurt wants to merge 1 commit intoopenai:mainfrom
rupurt:fix/bazel-memories-template-paths
Open

fix(bazel): replace askama templates with include_str! in memories#11778
rupurt wants to merge 1 commit intoopenai:mainfrom
rupurt:fix/bazel-memories-template-paths

Conversation

@rupurt
Copy link
Contributor

@rupurt rupurt commented Feb 13, 2026

Summary

  • The experimental Bazel CI builds fail on all platforms because askama resolves template paths relative to CARGO_MANIFEST_DIR, which points outside the Bazel sandbox. This produces errors like:
    error: couldn't read `codex-rs/core/src/memories/../../../../../../../../../../../work/codex/codex/codex-rs/core/templates/memories/consolidation.md`: No such file or directory
    
  • Replaced #[derive(Template)] + #[template(path = "...")] with include_str! + str::replace() for the three affected templates (consolidation.md, stage_one_input.md, read_path.md). include_str! resolves paths relative to the source file, which works correctly in both Cargo and Bazel builds.
  • The templates only use simple {{ variable }} substitution with no control flow or filters, so no askama functionality is lost.
  • Removes the askama dependency from codex-core since it was the only crate using it. The workspace-level dependency definition is left in place.
  • This matches the existing pattern used throughout the codebase — e.g. codex-rs/core/src/memories/mod.rs already uses include_str!("../../templates/memories/stage_one_system.md") for the fourth template file.

Test plan

  • Verify Bazel (experimental) CI passes on all platforms
  • Verify rust-ci (Cargo) builds and tests continue to pass
  • Verify cargo test -p codex-core passes locally

@rupurt rupurt force-pushed the fix/bazel-memories-template-paths branch 2 times, most recently from 4f46276 to a95476b Compare February 13, 2026 20:55
Askama resolves template paths relative to CARGO_MANIFEST_DIR, which
points outside the Bazel sandbox. This caused the experimental Bazel
CI to fail with "No such file or directory" errors for the three
memories templates (consolidation.md, stage_one_input.md, read_path.md).

Replace askama's #[derive(Template)] with include_str! + str::replace()
which resolves paths relative to the source file — working correctly in
both Cargo and Bazel builds. The templates only use simple variable
substitution so no askama features are lost.

This also removes the askama dependency from codex-core since it was the
only crate using it.
@rupurt rupurt force-pushed the fix/bazel-memories-template-paths branch from a95476b to c78e73b Compare February 13, 2026 20:59
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.

1 participant