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

Cannot install rust-analyzer binary if an instance of vscode is already running on Windows #3403

Closed
yoshuawuyts opened this issue Mar 2, 2020 · 8 comments
Labels
A-vscode vscode plugin issues S-actionable Someone could pick this issue up and work on it right now

Comments

@yoshuawuyts
Copy link
Member

Problem

Following up on #3092: I think I figured out what was causing EBUSY (in some cases)!

So I was prompted with installing the rust-analyzer binary again today, and it kept on failing with EBUSY. It then dawned on me: I already had a few VS Code instances open, so could that be what kept it busy? I tried it 4 times, and was prompted with EBUSY each time.

I then closed all running VS Code instances, opened a new instance, and suddenly downloading and installation worked! So I think it's fair to conclude: if VS Code is already running and already using the location the binary would be written to, installation will fail.

Solution

I'm not sure what the solution here is, but there seems to be a general issue around downloading a file into a location that's already in use. Perhaps the solution is to use version the binary name. Perhaps something using fd locks could work? I'm not a Windows expert so I can't say for sure, but a solution is probably in that corner.


Anyway, I hope this is helpful! I ran into this by accident when updating today, and am kind of thrilled that I managed to make it fail reliably!

@matklad
Copy link
Member

matklad commented Mar 2, 2020

Yeah, I guess what might do is:

  1. add release name to binary name

  2. schedule old binaries for deletion on the next reboot

  3. is pretty windows specific though... I wonder if the better solution is to implement some kind of "which version of rust-analyzer do you want to use" functionality, where we just keep a list of recently installed binaries. I am not too excited about going into that direction though, as I would prefer to keep the amount of features and logic in front-end to the absolute minimum.

Curious what folks with more windows experience thing about this? Note that on linux you can just overwrite binary of a running program, which makes such updates seamless without any explicit handing.

@matklad
Copy link
Member

matklad commented Mar 2, 2020

Hm, perhaps we should have just two binaries "rust-analyzer", and "rust-analyzer.next", and let the extension to try replace ra with ra.next on startup?

@yoshuawuyts
Copy link
Member Author

yoshuawuyts commented Mar 2, 2020

@matklad Whatever solution is settled on, I agree that we shouldn't expose more choices to end-users; people really appreciate it when updates just work. To that extent the current "download new rust-analyzer binary" might already be too much interaction.

@matklad
Copy link
Member

matklad commented Mar 2, 2020

To that extent the current "download new rust-analyzer binary" might already be too much interaction.

Agree with that, but I also think that we shouldn't do http requests without explicit user's action, so I probably don't want to just silently download stuff.

@Veetaha
Copy link
Contributor

Veetaha commented Mar 2, 2020

What about:

{
    "rust-analyzer.alwaysDownloadThatBinaryNeverAskMeAgain": true
}

Anyway, we could just handle that EBUSY prank and explicitly ask to close any other extension processes.
I also don't like the idea of allowing to choose the version of the lsp binary, since it might be incompatible with the extension version!
Storing all the binaries under different names could do the trick, but as they say, it's better not to leave trash in the first place...
Also, if I am not mistaken, I didn't see that any other extension code that handled this situation, though it doesn't relieve us from doing so!

@Veetaha
Copy link
Contributor

Veetaha commented Mar 2, 2020

And, regarding #3092 that EBUSY was a different kind of EBUSY anyway...

bors bot added a commit that referenced this issue Mar 9, 2020
3514: vscode: askBeforeDownload option r=matklad a=Veetaha

This is a small step towards #3402, also implements my proposal stated in #3403

Also renamed `BinarySource` to `ArtifactSource` in anticipation of nightlies installation that requires downloading not a binary itself but `.vsix` package, thus generalized to `artifact` term.

@matklad @lnicola 

Co-authored-by: Veetaha <gerzoh1@gmail.com>
@ivan
Copy link
Contributor

ivan commented Apr 6, 2020

I noticed that with rust-analyzer 0.2.117 on Windows + Remote SSH to Linux, I no longer get the EBUSY popup notification, it just silently fails when trying to download the binary. I keep vscode running on multiple machines that are sometimes out of reach, so my "get the thing to upgrade" workaround has been to run this on the Linux machine and then ctrl-c out after the launch retries stop:

while true; do killall rust-analyzer-linux; done

@Veykril
Copy link
Member

Veykril commented May 25, 2022

No longer relevant

@Veykril Veykril closed this as completed May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-vscode vscode plugin issues S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

6 participants