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

Can't launch executable in a workspace #7

Open
RReverser opened this issue Jun 18, 2022 · 4 comments
Open

Can't launch executable in a workspace #7

RReverser opened this issue Jun 18, 2022 · 4 comments

Comments

@RReverser
Copy link

RReverser commented Jun 18, 2022

I have a project structure like the following:

mylib:
  src/lib.rs
  Cargo.toml
  myapp:
    src/main.rs
    Cargo.toml

mylib/Cargo.toml includes myapp as a workspace member:

# ...

[workspace]
members = ["myapp"]

Visual Studio correctly shows myapp.exe as a target, and, via Rust Analyzer, invokes cargo to compile it, but then fails to launch saying that it's unable to start .../mylib/myapp/target/debug/myapp.exe. The reason, of course, is that in a workspace the target was produced under .../mylib/target/debug/myapp.exe, aka at the root of the project.

I suspect this is something that would be fixed by #5, but meanwhile perhaps a simple fix would be to always look for target folder at the root.

@RReverser
Copy link
Author

Side-note: thanks for creating this. I wanted this for a while and was mentally preparing myself for making a wrapper myself 😅

@cchharris
Copy link
Owner

Thanks for the issue! Sorry for the late response, was on vacation getting some sun :)

Yes, this is due to workspaces, which I haven't programmed support in for yet. The existence of a basic workspace changes the target directory, which breaks the path resolution. However, to support workspaces, I also have to support navigating up the directories to resolve to a single workspace, as well as virtual workspace identification.

Not too difficult, just have to put some effort into it.

As for #5 - if it provides the output information necessary, it would fix this. However, I do believe (and I have to check again) that that happens to be the missing information preventing me from relying on it.

@RReverser
Copy link
Author

Briefly looking at https://github.com/rust-lang/rust-analyzer/blob/master/crates/project-model/src/cargo_workspace.rs, it appears rust-analyzer itself relies on cargo metadata for workspaces, so I'd assume that should work here too.

Although, going one step further, since rust-analyzer already collects all this info, maybe there's a way to get this info out of rust-analyzer server itself, without repeating same steps in VS extension?

@cchharris
Copy link
Owner

Oh, interesting!

I'll have some free time this weekend and next week to look into this. I like the idea of seeing what we can extract from rust-analyzer. That does mean dipping into intercepting / sending our own language server requests, which I haven't done so far and is undiscovered territory.

I do like the idea of not having to manage our own TOML code, so #5 applying to this would be nice.

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

No branches or pull requests

2 participants