Rust recompiles all dependencies even after small changes

56 points Professional_Bag841

Hello everyone, i'm currently having some issue with Rust, where after each change I make rust recompiles all dependencies. I've found some post on this topic on stackoverflow, but unfortunately the solutions didn't helped in my case or maybe I misunderstood something while trying them out, so I came here to post my issue.

use bevy::prelude::*;

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_systems(Update, file_drag_and_drop_system)
        .run();
}

fn file_drag_and_drop_system(mut events: EventReader<FileDragAndDrop>) {
    for event in events.read() {
        info!("{:? }", event);
    }
}

I simply add an addition space after the ? character in the file\_drag\_and\_drop\_system function. Then press ctrl + s to save the change and after that use cargo run / cargo build. In both cases cargo recompiles all dependencies.

The things I've tried so far:

  1. Some people suggested, that the problem is that the build incremental isn't set to true.
  2. Others said, that setting the CARGO\_TARGET\_DIR environmental variable to a different folder might solve the problem.

config.toml in .cargo folder

Prior to my issue I also set up the cargo.toml file after the Bevy getting started guide.

[package]
name = "bevy_01"
version = "0.1.0"
edition = "2021"

[workspace]
resolver = "2" # Important! wgpu/Bevy needs this!

# NOTE: Remember to remove "dynamic_linking" before releasing your game! 
# Otherwise you will need to include libbevy_dylib alongside your game if you want it to run. 
# If you remove the "dynamic" feature, your game executable can run standalone.
[dependencies]
bevy = { version = '0.13', features = ["dynamic_linking"] } 

# Enable a small amount of optimization in debug mode
[profile.dev]
opt-level = 1

# Enable high optimizations for dependencies (incl. Bevy), but not for our code:
[profile.dev.package."*"]
opt-level = 3

I'm using VSCode with Rust Analyzer on Windows 10, Rust version v1.79.0-nightly
Thanks in advance for any help