Maybe allow rust_proc_macro rules to write files to OUT_DIR

Open
#3,884 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
28/100
Issue type
Feature
Clarity
Needs clarification
Activity status
Stale
Tech stack
rust
Domain
build-system

Research direction

No rules_rust source file or test is named. Start with the reported zngur/sailfish failure and the OUT_DIR behavior described here; the only source locations named are external/.../template.rs:45 and :97. Before implementation, decide whether writes should be permitted, then define a reproducible test and treat the issue as done when the chosen policy works for this case.

Written by the indexing model from the issue text.

Description

awaiting-response needs-design

I don't know if this is a good idea but cargo doesn't stop a proc-macro author from writing to OUT_DIR, however, bazel does error if a file is written to OUT_DIR. I don't think it's a good idea to let proc-macro authors write to OUT_DIR but it's already the case that some crates do so.

The original request comes from this bug: https://github.com/HKalbasi/zngur/issues/100. We transitively use sailfish which does some internal caching by writing compiled outputs to OUT_DIR.

This is the error

error: proc-macro derive panicked
  --> external/rules_rust++crate+crates_std__zngur-generator-0.8.0/src/template.rs:45:10
   |
45 | #[derive(Template)]
   |          ^^^^^^^^
   |
   = help: message: called `Result::unwrap()` on an `Err` value: Os { code: 30, kind: ReadOnlyFilesystem, message: "Read-only file system" }

error: proc-macro derive panicked
  --> external/rules_rust++crate+crates_std__zngur-generator-0.8.0/src/template.rs:97:10
   |
97 | #[derive(Template)]
   |          ^^^^^^^^
   |
   = help: message: called `Result::unwrap()` on an `Err` value: Os { code: 30, kind: ReadOnlyFilesystem, message: "Read-only file system" }

...
Dominant language
Starlark
Stars
857
Forks
701
Avg merge
4d 7h
Merged PRs (30d)
46

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from bazelbuild/rules_rust

All issues in bazelbuild/rules_rust

Similar issues

More Build System issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.