Skip to content
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

rust-analyzer doesn't work, fails to load workspace #2732

Closed
vvzen opened this issue Jun 9, 2022 · 4 comments
Closed

rust-analyzer doesn't work, fails to load workspace #2732

vvzen opened this issue Jun 9, 2022 · 4 comments
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug

Comments

@vvzen
Copy link

vvzen commented Jun 9, 2022

Summary

I am working a project that has got lots of different programming languages in it.

What's below is a simplification, but it's a basically a fully dockerized suite of services, so there's bash files, Dockerfiles, some python, etc..

.
├── ci-scripts
│   ├── before_script.sh
│   └── deploy_images.sh
├── docker-compose.yml
└── workers
    ├── python
    │   └── example_consumer.py
    └── rust
        └── rabbitmq-consumer
            ├── Cargo.lock
            ├── Cargo.toml
            └── src
                └── main.rs

I am running helix by cding all the way to rabbitmq-consumer, and then running hx src/main.rs.

Sadly, despite the health check passing fine for rust, I'm getting no help/errors/etc. when typing in a Rust source file.
I have installed rust-analyzer in a different place, since in working environment and I need this dev setup to work across multiple machines. /job/comms/pipeline/dev/myuser/opt/bin/ is in my PATH.

hx --health rust
Configured language server: rust-analyzer
Binary for language server: /job/comms/pipeline/dev/myuser/opt/bin/rust-analyzer
Configured debug adapter: lldb-vscode
Binary for debug adapter: Not found in $PATH
Highlight queries: ✔
Textobject queries: ✔
Indent queries: ✔

Reproduction Steps

I tried this:

  1. hx src/main.rs

I expected this to happen: the rust-analyzer worked and helped me with error reporting while typing in helix.

Instead, this happened: nothing

Helix log

If I look at ~/.cache/helix/helix.log, I see:

~/.cache/helix/helix.log
2022-06-09T22:56:09.689 helix_lsp::transport [ERROR] err <- "[ERROR rust_analyzer::lsp_utils] rust-analyzer failed to load workspace: Failed to read json file /net/rust-project.json: No such file or directory (os error 2)\n"
2022-06-09T22:56:09.689 helix_lsp::transport [ERROR] err <- "\n"
2022-06-09T22:56:09.689 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Error, message: "rust-analyzer failed to load workspace: Failed to read json file /net/rust-project.json: No such file or directory (os error 2)\n" }

I am not sure why it's looking for a rust-project.json file in /net/. In my case,/net/ is a storage mount (using autofs) where my home folder is mounted (/net/homes).

Platform

CentOS Linux release 7.9.2009 (Core)

Terminal Emulator

iterm2 - but I'm ssh-ing to another machine

Helix Version

helix 22.05

@vvzen vvzen added the C-bug Category: This is a bug label Jun 9, 2022
@sbromberger
Copy link
Contributor

sbromberger commented Jun 22, 2022

I've gone through the helix codebase and there's no string matching rust-project anywhere. Are you sure there's not something external (environment variable, config file, alias, ...) influencing your rust-analyzer?

That is - it appears that rust-analyzer itself is trying to load rust-project. This doesn't appear to have anything to do with helix.

@sbromberger
Copy link
Contributor

Ah, looking here, it appears that this is a rust-analyzer config option. Perhaps this will help:

There are three ways to feed rust-project.json to rust-analyzer:

Place rust-project.json file at the root of the project, and rust-analyzer will discover it.

Specify "rust-analyzer.linkedProjects": [ "path/to/rust-project.json" ] in the settings (and make sure that your LSP client sends settings as a part of initialize request).

Specify "rust-analyzer.linkedProjects": [ { "roots": […​], "crates": […​] }] inline.

@vvzen
Copy link
Author

vvzen commented Jun 24, 2022

Hi @sbromberger , thanks for having a look!
Does this file need to be filled in with specific data? or would a touch rust-project.json suffice ? I couldn't find much online.. (in the meantime, I will give it a try with just an empty file!)

@gabydd
Copy link
Member

gabydd commented Jul 14, 2023

this issue is also fixed by #5748

you can make a .helix/config.toml in the repo and set editor.workspace-lsp-roots = ["workers/rust/rabbitmq-consumer"] for helix to give rust-analyzer the correct root

@gabydd gabydd closed this as completed Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

4 participants