Skip to content

RA is unable to discover project workspace (regression) #5190

@meqif

Description

@meqif

A recent change made rust-analyzer unable to automatically discover the workspace. As a consequence, functionality such as textDocument/documentHighlight stopped working.

I'm using Emacs and the eglot plugin. Since I updated my local copy of the rust-analyzer repository to 57ed622 I've been unable to get RA to fully work in simple projects without any explicit workspace setup.

Here's a sample of the error message:

server-notification Thu Jul  2 13:47:59 2020:
(:jsonrpc "2.0" :method "window/showMessage" :params
          (:message "rust-analyzer failed to discover workspace" :type 1))

I've used git bisect to figure out when this regression was introduced, where 57ed622 (master) is the bad commit and 18a6dd4 is the commit that had been working correctly on my machine:

git bisect start 57ed622ec 18a6dd463

Eventually git bisect identified a03cfa4 as the bad commit, introduced in #5173:

❯ git bisect good
a03cfa49268d3938b55ceff046d04a75de8972b9 is the first bad commit
commit a03cfa49268d3938b55ceff046d04a75de8972b9
Author: Aleksey Kladov <aleksey.kladov@gmail.com>
Date:   Wed Jul 1 16:42:14 2020 +0200

    Automatically reload project on config change

 crates/ra_project_model/src/project_json.rs | 6 +++---
 crates/rust-analyzer/src/config.rs          | 2 +-
 crates/rust-analyzer/src/reload.rs          | 5 ++++-
 3 files changed, 8 insertions(+), 5 deletions(-)

Then, I checked out the master branch (@ 57ed622), reverted the bad commit and recompiled. At that point, rust-analyzer was working correctly again, which confirmed that a03cfa4 was indeed the cause.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions