Skip to content

Instantly share code, notes, and snippets.

@harrysarson
Created July 29, 2024 16:23
Show Gist options
  • Save harrysarson/d115dfc8ea3deee01e9d3d3b12f30b8f to your computer and use it in GitHub Desktop.
Save harrysarson/d115dfc8ea3deee01e9d3d3b12f30b8f to your computer and use it in GitHub Desktop.

Rust-analyzer causing rebuilds

I have some slighly odd config to make rust-analyzer work (in vscode). This ends up with rust-analyzer running cargo in a quite different way to how I run cargo via the terminal. This means each time rust-analzyer runs cargo after I have run cargo from the terminal it forces a rebuild (and visa-versa). Fix is to make rust-analyzer's cargo use a completely seperate set of build artifacts to the cargo I run from the terminal. Add this to vscode's json settings:

{
    "rust-analyzer.cargo.extraEnv": {
        "CARGO_PROFILE_RUST_ANALYZER_INHERITS": "dev",
    },
    "rust-analyzer.cargo.extraArgs": [
        "--profile", "rust-analyzer"
    ]
}

Credit for this goes to rust-lang/rust-analyzer#6007 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment