-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Unable to locate source lines when Rust subproject folder is opened in VSCode #17591
Comments
Sorry, should have mentioned, this is on macOS. |
I believe rust-analyzer provides VSCode with the problem info via LSP, so If it's providing the wrong relative path VSCode will show this error, but the cause is rust-analyzer. |
@davidbarsky: I re-read the steps you took. The problem is reproduced WITH the error in the code, so don't comment it out. |
This is on MacOS as well. Take a look at the screenshot I've attached: I have a relatively stock setup of rust-analyzer, and I'm not able to reproduce the behavior you are describing.
I mean, sometimes that is the case, but it doesn't seem to be applicable now. Is the message "The editor could not be opened because the file was not found" in the diagnostics pane, or...?
I uncommented "this is a deliberate error" and was able to click on the error in the diagnostics pane. After uncommenting it, i was also able to start VS Code in What version of rust-analyzer are you on? Did you change any settings? Our template has fields for this information, but it appears you've skipped past it, and without this information, I can't help you. |
@davidbarsky, could you confirm the main point: |
Yes, I can.
It brings me to the start of line 7, where the error actually is. |
And what OS are you on? Also, just double checking that you did not add the I'm on a fairly recent build of rust-analyzer, but the problem has been there for at least a couple of years, (and I suspect forever.) There are no global settings changes to rust-analyzer that I can tell. I've double checked VSCode's settings.json and for a global config.toml. |
Also, when you say "diagnostics pane" do you mean the Problems pane? Just making sure we're talking about the same thing. |
@davidbarsky, to ensure there isn't a pilot error, here are the minimal repro steps. Appreciate if you can restart from scratch and:
For me, this always gives the message "The editor could not be opened because the file was not found." |
I did not add this file, correct. I'm using the zip file that your gave me as a reproduction: the only change I made was adding a
What specific version of the rust-analyzer extension are you using? You can find this clicking, in the menu bar, View > Extensions. This will open the extensions pane in VS Code: please find rust-analyzer and tell and tell me what the version string is next to the name of the extension. Additionally, when you run
Yes, that is what I'm referring to.
Okay, I'm able to reproduce this and I understand what's going on here. For the future, please start issues with the steps you provided to save some time—what you provided initially was sufficient for us to reasonably reproduce your issue (we also have a template for bug reports: please use it; it makes our jobs far easier). Quick question: why do you want to open rust-analyzer in |
Good to hear.
The use case is a monorepo with a root workspace and team project folders under that, each containing multiple crates. The single workspace unifies dependency management. The team projects also have dependencies between them, but that does not necessitate a deeper hierarchy. Each team works within its own project folder, so opens VSCode to that folder. This works very well except for the current issue.
That imposes a constraint that neither Rust or VSCode inherently have. |
I think I caused this, #17605 should fix that (we were no longer using the source map) |
@Veykril, the issue I'm reporting has been around for a long time. Appreciate if you could test your patch against the quick repro steps, repeated here:
If the patch fixes the issue, step 5 should open the rust file at the line corresponding to the problem. Currently, step 5 triggers the message "The editor could not be opened because the file was not found." |
I would recommend opening at the root of the Cargo workspace for reasons I'll explain momentarily.
I understand that: I'm offering you a workaround. Anyways, the issue is not in rust-analyzer; it is in the interaction between
The right fix, I think, would be a weaker form of In any case, I'm closing this issue, as there's little we can reasonably do at the moment. |
Thanks for the info. BTW did this line get truncated:
|
Yes, that was an accident. I just fixed that. |
Guess I don't understand this, appreciate if you could break down: |
@davidbarsky, the current behavior is completely broken. I don't see how fixing rust analyzer to do the right thing could in any way be worse than the current situation. You're bringing up performance as a reason to not fix a broken behavior bug? Make it make sense, please. This bug is a serious one for those impacted by it and will not just go away by itself. |
Okay, having re-read this, I believe the issue is rust-lang/cargo#9887. Cargo reports file paths relative to the cargo workspace, not the current working directory which means the problem matcher regex will incorrectly receive That is rust-analyzer can't really do anything here as this is a bug with cargo handing us paths that do not correspond to the current working directory which is the only thing we can work with at the extension level. |
@Veykril, thanks for the reference, rust-lang/cargo#9887 shows that others have also indicated their frustration at this issue. Please see above where @davidbarsky indicates that this could be fixed in rust-analyzer, wonder what he has in mind? Be great to have a proposal no matter which component it is in, we can make sure it gets to the right team. |
A Critique of Pure NotMyProblemItisA recurring theme in this issue is: "there's nothing rust-analyzer can do, this is a vscode (or cargo) issue." If VSCode (or cargo) was broken in a way that some fundamental rust-analyzer functionality was broken, for sure you would be on the case, investigating, filing bugs against vscode/cargo and pushing until a fix was made that restored rust-analyzer's own functionality. This issue falls into exactly the same category, except that you folks seem disinclined for whatever reason to do anything about it. Case in point, @davidbarsky lets slip that "rust-analyzer could fix this in the extension", but stops responding when asked how. Anyhow, this issue is a cross-boundary issue, and you own one half of the cross-component chain, and it's your components' behavior that is impacted. So it is really up to you to pursue the issue through to completion. Instead, you throw your hands up and leave it up to a normal user, me, who has made considerable efforts to get this fix underway by providing clear steps to reproduce the issue, to figure out the innards of what might be going wrong in order to be the intermediary between the two teams? What an apathetic situation. As they say, where there's a will there's a way. I know this post may lead to petulant refusal, but TBH it looks like we're already there. Closing this issue summarily in this half-investigated state is totally inappropriate. I hope that some of the leads will take notice. |
While I understand that you are frustrated, your tone is coming off as needlessly hostile when we are trying to help you. Threatening professional repercussions in the form of "I hope that some of the leads will take notice" falls into the category of hostility. I will involve the moderation team if you continue to behave in this way. For the future: we, or any other maintainer, are under no obligation to respond or help you, for any reason whatsoever. The software here is provided as is, without warranty of any kind.
I'm only responding to this in a show of good faith: I was speaking to several members of the Cargo/compiler teams privately about a weaker, diagnostics-only form of
We had other priorities. I tried out a naive solution with Additionally, please refrain from @'ing me. I check my GitHub notifications multiple times per day. |
You closed the issue and stopped responding to questions which is what motivated my critique. Is that what you call "trying to help"? Sorry, you words are not not congruent with your actions.
I do hope the leads take notice. I am making the case for this to be reopened and worked on. That is seen by you as a threat? Ridiculous. You're the one threatening senselessly. To be clear, I'm not here to have my time wasted - if you can help then do so. I am desperate to have this issue fixed. Period. If you think this is personal I have nothing to say to you.
Github users are not mind readers and can only respond to observed actions. It would have been better to mention that investigations were ongoing and to leave the issue open. By the way, it is still closed. In any event, this is more appealing a discussion to have. One idea - perhaps just add a simple API to let rust-analyzer know which folders the the a) build and b) diagnostics are relative to? I understand it's a security issue print the absolute paths of these two folders (build and diagnostics roots) to the console or to a build log, but don't think it's a security issue to pass the absolute paths via an API to another component. |
@davidbarsky are you going to reopen this issue? Closing an issue cuts it off from anybody else taking an interest in it and dooms it to non-resolution. You mentioned that you "check my GitHub notifications multiple times per day" so hoping for a speedy response. |
@davidbarsky, kindly refrain from this issue going forward, done with this weirdness WADR. @Veykril, I've looked at rust-lang/cargo#9887, and it may be relevant here. Now this present issue is that we can specifically either get build paths to work OR diagnostics paths to work, but not both at the same time, conditioned on |
Minimal repro: rust_analyzer_workspace_bug.zip
The attached workspace has these files:
Quick Repro steps:
code rust_analyzer_workspace_bug/subproject
. (This opens the project atsubfolder
rather than at the root, in order to reproduce this issue.)main.rs
.)Observe: a tab opens with the message "The editor could not be opened because the file was not found."
Expected: the file to open with the cursor on the line containing the bug.
Note: this bug can be mitigated by adding the file
subfolder/.cargo/config.toml
, with the contents:However, this fixes the above problem, only to introduce an equally serious one: debugger symbols are incorrectly mapped, and breakpoints are not resolved correctly.
I haven't found any way to have both of these work simultaneously:
So I've needed to comment out the lines in config.toml when debugging, and re-enable them when just compiling.
This is tedious and frustrating and would really appreciate a fix asap.
The text was updated successfully, but these errors were encountered: