How to change the location of "target" when building? (IntelliJ IDEA w/ Rust plug-in)

Hi, I'm using IntelliJ IDEA Ultimate with the Rust plug-in. Is there any way to change the location of the "target" directory when building?

The rustc --out-dir option is probably what you want, but I don’t know how to specify that to IntelliJ (or Cargo, for that matter).

I see. I'm still trying to figure out how to do it...

The reason is the directory is under iCloud backup management (on my Mac), and I want to eliminate those backup traffic.

Yup, I figured it out... Just place:

[build]
target-dir = "/Users/yourname/yourlocation/"

in the a .cargo/config file.

There is STILL one more problem: this seems to be a generic target location for all project builds, which they are not separate sub-directories for each project/app. So, anyone knows how to make each project/app builds go into "/Users/yourname/yourlocation/my-specific-app" respectively?

This explains that:

  • --out-dir can be used to specify artifact output (Such as executables and shared libraries).
  • --target-dir can be used to specify build output (Entire build. This essentially moves ./target).
1 Like

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.