OUT_DIR not set even though build scripts exists!

I have 2 similar projects using OUT_DIR one of them works fine while the other doesn't.
Project 1 which works fine, but my own copy structured similarly like

├── build.rs
├── Cargo.lock
├── Cargo.toml
├── src
│   ├── lib.rs
│   ├── model
│   │   ├── mnist.onnx
│   │   └── mod.rs
│   └── state.rs

cargo build fails with the error :

error: environment variable `OUT_DIR` not defined at compile time
 --> src/model/mod.rs:2:22
  |
2 |     include!(concat!(env!("OUT_DIR"), "/model/mnist.rs"));
  |                      ^^^^^^^^^^^^^^^
  |

So the build.rs file exists but it seems that cargo cannot detect it? Any ideas why? Also possible solutions?

Is bulid a typo in the actual file name or just the visual?

1 Like

Sorry, typo, fixed it

Wow, It seems that was the issue. Now facing another one, will mark as solved once it all works. Thank you!

Edit: I was thinking over such a silly mistake for 3 days...

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.