rust-lang / rust-lang/rust-analyzer

Spurious failure to load a `.rs` file from `OUT_DIR`

Open
#12,088 7 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-vfs C-support
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

FWIW I'm seeing this in a multi-crate repository (tagged to a commit that exhibits the issue). It appears that RA may be trying to use the wrong path relative to the crate to load the included file? The project(s) build fine with cargo, so the error is simply wrong.

image

The path in the error message is (relative to repository root):
libretro-rs/target/debug/build/libretro-rs-sys-37adac34f8f4cbf3/out/libretro.rs

But the path I would expect is:
libretro-rs-sys/target/debug/build/libretro-rs-sys-86130f2702103941/out/libretro.rs

However, the path in the error message does exist, since the libretro-rs crate depends on the libretro-rs-sys crate in the same repository. It appears that RA is getting confused and I don't think the solution should involve adding configuration to straighten it out. If cargo can figure it out then RA should be able to as well.

$ cargo build
   Compiling libretro-rs-sys v0.1.0 (/home/adam/Repos/libretro-rs/libretro-rs-sys)
   Compiling libretro-rs v0.1.3 (/home/adam/Repos/libretro-rs/libretro-rs)
   Compiling example v0.1.0 (/home/adam/Repos/libretro-rs/example)
    Finished dev [unoptimized + debuginfo] target(s) in 0.93s

If this issue is unrelated, I'll make a new issue.

Originally posted by @adam-becker in https://github.com/rust-lang/rust-analyzer/issues/10178#issuecomment-1107666673

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue in the linked multi-crate libretro-rs repository and compare rust-analyzer's reported OUT_DIR path with the path produced by cargo build. Trace how the libretro-rs and libretro-rs-sys crates are resolved, then verify that rust-analyzer loads the generated libretro.rs from the expected crate-specific target directory.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.