Skip to content

CACHEDIR.TAG not created if rust-analyzer runs before cargo build #14281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
problame opened this issue Jul 21, 2024 · 4 comments
Closed

CACHEDIR.TAG not created if rust-analyzer runs before cargo build #14281

problame opened this issue Jul 21, 2024 · 4 comments
Labels
A-caching Area: caching of dependencies, repositories, and build artifacts C-bug Category: bug S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.

Comments

@problame
Copy link

problame commented Jul 21, 2024

Problem

After checking out a Rust/Cargo project from Git, if rust-analyzer is run before the first cargo build, the target/CACHEDIR.TAG is missing

Steps

  1. Check out some default Rust/Cargo project that has target directory excluded from Git.
  2. Open in a VSCode code . that has rust-analyzer extension installed
  3. Wait a bit until target/analyzer/CACHEDIR.TAG is created
  4. cargo build => cargo build not creating target/CACHEDIR.TAG

Possible Solution(s)

Revert https://github.com/rust-lang/cargo/pull/13132/files

Notes

I verified that this reproduces on both macOS and Linux.

Version

cargo 1.79.0 (ffa9cf99a 2024-06-03)
release: 1.79.0
commit-hash: ffa9cf99a594e59032757403d4c780b46dc2c43a
commit-date: 2024-06-03
host: aarch64-unknown-linux-gnu
libgit2: 1.7.2 (sys:0.18.3 vendored)
libcurl: 8.6.0-DEV (sys:0.4.72+curl-8.6.0 vendored ssl:OpenSSL/1.1.1w)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Debian 11.0.0 (bullseye) [64-bit]
@problame problame added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Jul 21, 2024
problame added a commit to neondatabase/neon that referenced this issue Jul 21, 2024
Backup tools such as restic recognize this.
More info: https://bford.info/cachedir/

NB: cargo _should_ create the tag file in the `target/` directory
but doesn't if the directory already exists, which happens frequently
if rust-analyzer is launched by your IDE before you can type
`cargo build`. Hence, create the file manually here.
=> rust-lang/cargo#14281
@weihanglo
Copy link
Member

Where did you configure target/analyzer/CACHEDIR.TAG?
The directory doesn't seem to be created when trying to reproduce it with Rust Analyzer v0.3.2037.

Could you give a complete reproducer like

  • Which repo you cloned and run
  • The version of the rust-analyzer extension

@weihanglo
Copy link
Member

@weihanglo weihanglo added A-caching Area: caching of dependencies, repositories, and build artifacts S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. and removed S-triage Status: This issue is waiting on initial triage. labels Jul 21, 2024
@problame
Copy link
Author

problame commented Jul 21, 2024

Where did you configure target/analyzer/CACHEDIR.TAG?

Hm, I configured target/analyzer in vscode

...
    "rust-analyzer.server.extraEnv": {
        "CARGO_TARGET_DIR": "target/analyzer"
    },
    "rust-analyzer.check.extraArgs": [
        "--target-dir=target/analyzer"
    ],
...

(Snippet from here: rust-lang/rust-analyzer#6007 (comment) )

So, I guess we can dedupe this into #12441

@weihanglo
Copy link
Member

Yeah that seems like a dup. I am going to close this.
Would you mind sharing ideas in #12441 about why CACHEDIR.TAG is critical in this case, and why a separate target dir is needed? We can discuss there.

@weihanglo weihanglo closed this as not planned Won't fix, can't repro, duplicate, stale Jul 21, 2024
problame added a commit to neondatabase/neon that referenced this issue Jul 22, 2024
Backup tools such as `tar` and `restic` recognize this.
More info: https://bford.info/cachedir/

NB: cargo _should_ create the tag file in the `target/` directory
but doesn't if the directory already exists, which happens frequently
if rust-analyzer is launched by your IDE before you can type
`cargo build`. Hence, create the file manually here.
=> rust-lang/cargo#14281
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-caching Area: caching of dependencies, repositories, and build artifacts C-bug Category: bug S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.
Projects
None yet
Development

No branches or pull requests

2 participants