-
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
Allow rust path configuration #3154
Comments
rust-analyzer never invokes https://github.com/rust-analyzer/rust-analyzer/search?q=rustup&unscoped_q=rustup |
I was thinking about Cargo binary, as it is in the same folder as rustup if intalled using that tool. I have changed the title, thanks! |
If I'm allowed to be a little snarky, we already have this, it's called the I'm not sure if I personally see too much value adding another way to configure it (not really any harm either, apart from added complexity of threading the configuration through to where it's needed) , I'd love if you shared your use case, as it makes it easier to evaluate :) |
I think we should honor |
This is the place where we need to take |
In my case, this issue would be related to how vscode works in Solus (Linux distro), as explained in microsoft/vscode-python#1338 (comment). In short, the path that vscode is using internally (not happening in its embedded terminal) does not take into account the user-configured one, so that's why I had to manually add rustup path in Rust-rls extension to make it work. Therefore, with this extension I'm getting an error when it executes |
@yaymalaga see #2496 (comment). We had something about this in the install notes, but it was dropped in #3140. |
One more rustc place that needs to be taken care of in this issue: https://github.com/rust-analyzer/rust-analyzer/blob/585eef1d8c79e24b7788363cf3a5bc7c9c3bc963/crates/ra_project_model/src/sysroot.rs#L112 Also now we call There are also two places in rust-analyzer's coe that might need a fix either, but I'm not sure: |
This is precisely what I want to avoid by setting cargo path directly in settings.json, instead of modifying my global PATH. |
I would also like to be able to set the cargo path directly in |
For my personal needs, the work done as part of #4329 is more than enough. However, the issue itself is just partially fixed, so I'm not sure if I should close it or keep it opened. |
Ok, so I've though about this a bit, and I am still convinced that specific configurations are a wrong approach here. However, I see how it might be awkward to configure env on some OS. So I propose the following solution:
I like this more, because it provides a clear and general mechanism -- overriding env vars. |
One issue with solving this via VSCode settings is that VSCode doesn't currently support per platform settings. That's not a |
There is a related issue that causes me problems, which this would solve: some crates require custom environment variables to be passed to |
@yaymalaga we now automatically detect (Marking |
@mthebridge there's a |
@lnicola Ah awesome -thanks, yes, that's exactly what I needed! |
Hi, I had a quick go with
But that didn't seem to work Typically I end up with this otherwise in the problems listing
Edit there is a "rustc" option under .cargo/config so perhaps this setting could be used / picked up from |
Hello all! I have been looking into this issue as part of Microsoft's Hack Week. I've written up my understanding of the problem along with a potential solution. I would love some feedback on whether my understanding is consistent with the understanding of others as well. ProblemThere is not currently a way to configure rust analyzer to use a specific build of rustc in a VScode project or workspace. Why would you need to do this?While a user could specify what version of rustc is used via their PATH environmental variable, that would make it the version of rustc used across their system. A user might be developing using one version of rustc in one project/workspace and a different version in another. It's not ideal to modify their PATH each time they switch projects/workspaces. Proposed solutionAdd a configuration setting to specify a path to a specific build of rustc. For example, if a user were to add this line to their settings.json file in VSCode:
rust-analyzer would then use that build of rustc for any VSCode project using the same settings.json file. How to you find out what version of rustc rust-analyzer is using?It's a bit hacky at the moment, but if you add these print lines to And then run this test It will output the cargo version which (I need to confirm this) should indicate what version of rustc is being used by Rust Analyzer. |
I am not a fan of rust-analyzer-specific configuration for rustc version. Presumably, the user would like to compile their project without rust-analyzer as well, so they already have some way to override rustc. We should teach rust-analyzer to use that config, instead of asking the user to configure both ide and command line. So I’d:
|
That being said, having client side setting which translates to RUSTC env var might be a good, discoverable addition, after we make sure that all cases that could just work indeed work. |
My use case is as such:
So, being able to specify the paths for executables would help (somewhat) in my case. Without this, I'm stuck with https://github.com/flathub/org.freedesktop.Sdk.Extension.rust-stable/ |
You can use |
I have a similar need about the path to cargo. Xref with #16204 |
Automatic Rustup
I think this is pretty much implemented (given the points raised in the discussions) |
Automatic Rustup
In Rust (rls) vscode extension, it is possible to specify the rustup path by adding the "rust-client.rustupPath" key in the settings.json.
Would it be possible to have the same option in rust-analyzer? This would enable the extension to directly know about the location of cargo, rustc, etc
The text was updated successfully, but these errors were encountered: