nova-rust icon indicating copy to clipboard operation
nova-rust copied to clipboard

[BUG] `target/` gets flushed when a background syntax check is running (on save)

Open valeriansaliou opened this issue 2 years ago • 2 comments

Describe the bug

Whenever I save a Rust file from Nova, nova-rust performs a background check of the syntax and errors, which works perfectly fine. However, whenever this runs, I lose my target/ cache from the previous build in my terminal (manual build using eg. cargo build), which makes the next build slow.

Also, when the background syntax check operation runs, and is still running while I attempt to call: cargo build in my terminal, I also see:

Blocking waiting for file lock on build directory

This shows that something is sharing the same target/ directory in my local project, and I'm not sure this used to happen in the previous nova-rust versions.

My options are as follow in the screenshot:

image

To Reproduce

  1. Build your Rust project using cargo build
  2. Re-build your Rust project using cargo build (the target/ cache is used)
  3. Change a file, save it in Nova
  4. Try running cargo build (slow!), the cache was purged by the extension

Expected behavior

My target/ build cache would stay populated, and I wouldnt have to compete w/ another build lockfile.

Versions (please complete the following information):

  • macOS: 12.4
  • Processor: Apple Silicon
  • Nova 9.3
  • Extension Version 2.1.0
  • Rustc version rustc 1.60.0 (7737e0b5c 2022-04-04)

valeriansaliou avatar May 31 '22 19:05 valeriansaliou

Rust Analyzer uses Cargo for issue checks on save (cargo check or cargo clippy depending on the preference you set as shown above), which is why your target directory is being shared.

Your best bet to prevent sharing is probably to add --target-dir ./target-check to the Additional Arguments preference in the Issues section (see your screenshot above). You can of course use whatever directory name suits you, but you'd need to add it to your .gitignore. I'll note that you can set this preference per-project if it doesn't make sense as a global preference. (Project -> Project Settings... -> Rust extension)

kilbd avatar May 31 '22 20:05 kilbd

Thank you, this worked perfect to fix the issue!

In terms of developer UX, I'd advise adding this to the README, or maybe even auto-configuring the default --target-dir to be some temporary folder owned by Nova (possibly w/ a permanent cache), outside of the Rust project. Even if I know the standard Rust tools share the target/ folder between commands, something definitely collides here.

valeriansaliou avatar May 31 '22 20:05 valeriansaliou