Skip to content

Conversation

@user1823
Copy link
Contributor

@user1823 user1823 commented Jan 6, 2026

Anki's build scripts (ninja) set CARGO_TARGET_DIR for their own execution. But, when running cargo commands directly (like cargo check), those commands don't inherit that environment variable and use the default target/ directory instead, leading to duplicate builds.

After this change, all cargo commands (check, build, test, etc.) will use the same cache, saving storage space.

Anki's build scripts (ninja) set CARGO_TARGET_DIR for their own execution. But, when running cargo commands directly (like cargo check), those commands don't inherit that environment variable and use the default target/ directory instead, leading to duplicate builds.

After this change, all cargo commands (check, build, test, etc.) will use the same cache, saving storage space.
@user1823
Copy link
Contributor Author

user1823 commented Jan 6, 2026

One possible issue with this:
IDEs running rust-analyzer in the background may cause file lock issues, especially on slower hardware. These issues can be avoided by preventing rust-analyzer from running background cargo checks. Real-time error checking will be lost, but rust-analyzer can still be used for code completion, go-to-definition, etc. cargo check can be run manually to see errors.

Relevant: Large projects and performance - Zed editor

VS code settings:

{
  "rust-analyzer.checkOnSave.enable": false,
  "rust-analyzer.cargo.buildScripts.enable": false
}

@abdnh
Copy link
Collaborator

abdnh commented Jan 6, 2026

That's great. I never noticed Anki is eating up 100 GB of my drive...

We should update the "Cleaning up build files" section in docs/development.md

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants