Cargo :: out of dir builds :: push "/target" elsewhere

  1. I have a project located at ~/foobar

  2. Currently, the target directly is at ~/foobar/target

  3. I would like the target directory to go to ~/target-foobar (out of the ~/foobar path).

Is this possible with cargo? [The motivation is that a number of search tools I use operate at the "project" level, and end up searching through all the ~/foobar/target directory, which drastically slows things down. Instead of reconfiguring each tool separately, I would prefer to just move the target elsewhere.]

To just add to this insanity, my "/target" is currently 4.1G on one particular project.

1 Like

You can set CARGO_TARGET_DIR or use the --target-dir option.

Yes :slight_smile:

https://github.com/rust-lang/cargo/pull/1657

@cuviper , @hellow : I am using IntelliJ. Thus, the

build.target-dir

is probably the solution want. Which file / where do I put that? (googling links back to the github issue @hellow linked to)

The Manifest Format - The Cargo Book <-- for build.target-dir

I think it actually goes in the local config, not the manifest.
https://doc.rust-lang.org/cargo/reference/config.html