-
Notifications
You must be signed in to change notification settings - Fork 762
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
bug: VS Code fails to initialize workspace with Cargo (Rust Alanyzer) #1178
Comments
I'm experiencing the same bug, but I'm not sure if this is the fault of |
Hey, @spikespaz. I found a quick fix for this problem. Add the shims folder to the env vars of your # Import the default profile
if [ -f "/etc/profile" ]; then
source "/etc/profile"
fi
# Set the list of directories that Bash/Zsh searches for programs
path=(
$HOME/.asdf/shims
$path
) I want to mention my gratitude to @baliestri, who helped me solve this problem. |
|
So in an Arch derivative, which @soukyomi also it's definitely |
Only if you want you can write to the I use it as follows: path=(
$HOME/.asdf/shims
$HOME/.local/{bin,sbin}
/usr/{bin,sbin}
/usr/local/{bin,sbin}
$path
) |
This issue happens to me with some tools and not others. I have experienced this with Rust Analyzer myself, but didn't stick with Rust long enough to resolve or investigate in any meaningful way. Given the unpredictable nature of this, I expect that this depends on how the plugin itself tries to find tools and what it does in the background to resolve missing tools. For instance, I use the The Is sourcing it in the |
Because the extension isn't looking at your |
@spikespaz As you say in the initial issue:
They can if they look in the right place.
Standardized locations for tools installed at the system level, non-version managed.
Yes, it is not Nix. Our comments on that are here https://asdf-vm.com/guide/introduction.html Can someone speak as to why @bitterteriyaki method supposedly works? I am inclined to mark this as unfixable by |
@jthegedus it's such a fundamental issue for users of asdf, like it's one of the first things I stumbled on. Right now the best solution for me is to run edit: I know it's not asdf issue per se but people think it is, for example look here: https://elixirforum.com/t/failed-to-run-elixir-command-error-in-vs-code/31047/6 edit2: so in my case when I have been sourcing edit3: I've straced vscode and it doesn't look to me like it's directly sourcing the files, my assumption is that something launching it has already done that. |
I am not sure what we can do about it though. Copying shims to |
I was following this https://asdf-vm.com/guide/getting-started.html#_3-install-asdf and if there was a mention like "if you're facing issues with your code editor/3rd party tooling being unable to find binaries then add this to your ~/.bash_profile or whatever ..." then it would save a ton of my time (and others as well). |
Is this captured in VSCode documentation anywhere? Before we recommend to all users in the docs I want to understand the issue completely. Is VSCode strictly tied to your Shell? A specific Shell, or the default Shell? If I use Fish will VSCode run that Shell's equivalent of profile? Lots of questions to understand what is actually happening before we can recommend any solution. You have done some great digging, thanks @Rotwang If you have more time to further investigate that would be appreciated. |
This is key. If the behavior of VSCode is not documented anywhere, we cannot document a proper solution to this problem in the asdf docs. If VSCode doesn't clearly explain how it finds commands we can provide any official suggestions on how to work around the issue. Based on the conversation here there is nothing indicating any issues with asdf itself. If there aren't official docs on how VSCode handles this we should close this issue. |
I have been wrestling with this for quite a while. I always launch vscode from the shell, which is generally helpful, vscode inherits the path and everything seems good. My workflow for working on multiple projects is to open multiple vscode windows, and (no evidence for this) it seems like the directory that you open the initial window from is the environment that works. Actually, I just did a test locally - I exited vscode, loaded a project with an asdf config, and then opened another project. As I expected, I saw the bad behavior from a specific extension. My takeaway here is that having the shims dir on the path is not sufficient in all cases. I completely agree that it's unclear how to really address this - it probably depends on extension implementations to some extent. My intuition says that a vscode extension would be the right answer, but I have no clue if vscode exposes an API that would a) be useful and b) work universally. I had a thought a few minutes ago, that Not sure if any of this is helpful 🤷♂️ |
This feels relevant: microsoft/vscode#130493 But, I don't really know how |
There are two questions to be answered in my mind: A) Actually vscode tends to launch it's children through a login shell, here is
What you can see here is vscode starting a
So here is the reason, I had my When I changed my user's shell ( B) It's difficult to tell on linux because there are so many different ways you can set up your graphical environment. There are many desktop managers (login things that make you enter password and they spin up your gnome/kde/fluxbox/etc. for you) that can be set up in a different way. I'm using ubuntu 20.04 with A note on PAM we shouldn't forget that on linux the authentication is done by PAM which is going to provide its own variables from Having said all that what I did in the end was:
I hope that helps. edit: typo and minor semantic mistake |
AFAIK, |
Not quite, if you look up the Conclusion is that |
@keithlayne That VSCode Issue is interesting, thanks. You may be interested in https://github.com/asdf-community/asdf-direnv @Rotwang That is a lot of very useful information, thanks for your time & effort! So what I have learned is this:
What we need to do:
Does this sound reasonable to everyone? @Stratus3D ? I wonder how *Nix and Docker-based version-managed projects handle these issues, or is their workflow that the IDE Extensions just not use the version managed tooling? |
This is interesting, because it seems to conflict with my experience with multiple workspaces open. This isn't super easy to test, but I have an extension that only works when I load from the console (avoiding the |
Perhaps I got lucky. I had the below behaviour:
So it is correctly trying to resolve the tool from the directory it was opened in and not from. At least for me, and with this particular Extension. The Deno extension might just be super resilient. As for my setup while testing this:
Extension variance is definitely a factor in this, but not a predictable one and certainly not solvable by us. User shell setup is also a nightmare, hence why we didn't want to get into the game of automatically modifying configs. Additionally, I just got VSCode@1.69 which has unrelated, but further Shell integrations
So VSCode are actively working in this area and can potentially introduce changes which would affect our advice. We must remain aware. I would like to not get stuck in the weeds of comparing each others Shell setups if we agree on the "what we need to do" items I outlined above. |
sudo ln -s ~/.asdf/shims/cargo /usr/bin/cargo worked for me |
Problem is also being discussed in rust-analyzer/issues/3154 |
This comment was marked as outdated.
This comment was marked as outdated.
This seems like a VSCode issue rather than |
Describe the Bug
I am using the rust-analyzer extension for Visual Studio Code and when I open a Cargo project I see:
I have had nothing but problems trying to get other similar tools to find the shims from asdf. There has to be a method, as it is everything that I try to use with asdf-managed tools is simply inoperable.
I cannot find a setting in Code that allows me to change the path to the toolchain.
Steps to Reproduce
asdf plugin add rust
asdf install rust latest
asdf global rust latest
asdf reshim
rm -rf ~/.asdf/shims
asdf reshim
Expected Behaviour
The IDEs and other tools should be able to find software managed by asdf. I have tried adding the initialization script to both
.zshrc
and.profile
(ZSH is my login shell).Everything works fine from the command line.
Actual Behaviour
No tooling I try (specifically VS code in this case) can ever find binaries from
~/.asdf
.Environment
OS: Linux jacob-thinkpad 5.17.0-2-MANJARO #1 SMP PREEMPT Fri Feb 25 11:28:23 UTC 2022 x86_64 GNU/Linux SHELL: zsh 5.8.1 (x86_64-pc-linux-gnu) ASDF VERSION: v0.9.0 ASDF ENVIRONMENT VARIABLES: ASDF_DIR=/opt/asdf-vm ASDF INSTALLED PLUGINS: flutter https://github.com/oae/asdf-flutter.git master 1f5b9e2 java https://github.com/halcyon/asdf-java.git master b0341fd nodejs https://github.com/asdf-vm/asdf-nodejs.git master 364c078 python https://github.com/danhper/asdf-python.git master 57a4d72 ruby https://github.com/asdf-vm/asdf-ruby.git master de49662 rust https://github.com/code-lever/asdf-rust.git master 0c88f99
asdf plugins affected (if relevant)
rust
The text was updated successfully, but these errors were encountered: