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

Bogus linkedProjects paths being created #14480

Closed
kpreid opened this issue Apr 4, 2023 · 4 comments · Fixed by #14481
Closed

Bogus linkedProjects paths being created #14480

kpreid opened this issue Apr 4, 2023 · 4 comments · Fixed by #14481
Labels
C-bug Category: bug

Comments

@kpreid
Copy link
Contributor

kpreid commented Apr 4, 2023

Today (in particular, since #14366 got released) I have seen a couple reports of people getting inappropriate linkedProject configurations, e.g. this URLO thread.

rust-analyzer failed to load workspace: Failed to read Cargo metadata from Cargo.toml file c:\Cargo.toml, Some(Version { major: 1, minor: 68, patch: 2 }): Failed to run "cargo" "metadata" "--format-version" "1" "--manifest-path" "c:\\Cargo.toml" "--filter-platform" "x86_64-pc-windows-msvc": cargo metadata exited with an error: error: manifest path c:\Cargo.toml does not exist

I don't recall where I saw the other case, but I believe it was also on Windows with a path of D:\Cargo.toml.

This suggests that there may be a bug which is causing manifest paths that don't actually exist to be added to settings.json. Since I don't use Windows myself, I don't have a repro for you (and couldn't easily trigger it on my own macOS); I'm just writing this in the hopes that the observation will be useful and save more beginners from a bad experience.

@kpreid kpreid added the C-bug Category: bug label Apr 4, 2023
@Veykril
Copy link
Member

Veykril commented Apr 4, 2023

Oh no, seems the yes and no buttons for the message got mixed up 😓 Will fix that in a bit, I think we should do a midweek release here since that's gonna trip up a lot of people

@c-git
Copy link

c-git commented Apr 5, 2023

Happen for me too on linux

It happens for me as well on Ubuntu. It started recently and while it does seem that the yes and no buttons are likely reversed that is not the real problem that I am having.

To clarify when I click "Yes" nothing happens, when I click "No" it adds the following to .vscode/settings.json

"rust-analyzer.linkedProjects": [
        "/rust/Cargo.toml"
    ],

Description of the problem (and initial ideas of what the problem might be)

This happens on my leetcode repo and my suspicion is that the problem is related to the fact that the rust project is in a subfolder not at the root of the vscode project.

The problem I am having is that when I click "No" that line gets added and until I remove it rust-analyzer does not work anymore and the icon at the bottom turns red and stays red (See screen shot below).

Screen shot of red plugin

Error logs

Opening the logs the message I get is:

[ERROR rust_analyzer::main_loop] FetchWorkspaceError:
rust-analyzer failed to load workspace: cd "/rust" && "cargo" "--version" failed: No such file or directory (os error 2)

[ERROR rust_analyzer::main_loop] FetchWorkspaceError:
rust-analyzer failed to load workspace: cd "/rust" && "cargo" "--version" failed: No such file or directory (os error 2)

[ERROR rust_analyzer::main_loop] FetchWorkspaceError:
rust-analyzer failed to load workspace: cd "/rust" && "cargo" "--version" failed: No such file or directory (os error 2)

I'm not sure if there are confounding factors at play because if you look at my settings.json you'll see I have a command very similar to that one which I use to run my code.

And for clarity before that message started coming up and changing my settings rust analyzer used to work fine.

Steps to reproduce the problem

  1. Clone my repo https://github.com/c-git/leetcode
  2. Then in vscode open the leetcode folder as a workspace.
  3. Then open any of the files in the rust folder other than lib.rs and the pop up should show.
  4. Click "No"
  5. Then the problem happens and rust analyzer stops working.

Current suspected cause of the problem

After having read the logs again and looking at the lines added I think the problem is the leading "/" because it is trying to cd into /rust which doesn't exist.

PS. In PyCharm the rust plugin will actually add the mod xxx; (were xxx is the name of the file I want to add to lib.rs) for me when I click yes on a similar prompt. This is nice to have but I was getting along fine without it. I've since found a work around that I am using but decided to mention it in case this information helps. The workaround is to click "Don't show this again" which adds a line to settings that causes the prompt to not come up anymore. I've removed the fix from my settings for now from my repo to facilitate reproduction.

@Veykril
Copy link
Member

Veykril commented Apr 6, 2023

This should be fixed on the latest nightly (we also pushed out a new a stable release with the fix, but it seems the fix didn't make it in?)

@lnicola
Copy link
Member

lnicola commented Apr 6, 2023

Yeah, looks like nothing got in that new stable release. I'm not sure yet what I did wrong.

We should probably do these more often :(.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants