Rust Analayzer extension activation failed

I have installed the newest version of rust analyzer for vscode and have the rust analyzer installed as well. However, whenever I start VSCode to get Rust Analyzer started,I get this issue in the extension outputs.

2023-08-03 19:48:19.901 [error] Activating extension rust-lang.rust-analyzer failed due to an error:
2023-08-03 19:48:19.901 [error] Error: Cannot find module 'c:\Users\shred\.vscode\extensions\rust-lang.rust-analyzer-0.3.1607-win32-x64\out\main'

I'm unsure why this is happening, as the settings for the extension all seem to be configured properly. I've tried reinstalling the extension as well as the rust-analyzer itself and none of that has worked so far.

Have you checked whether the Rust Analyzer binary exists at this location? If it does, you should be able to execute it (RA is a server program).

that's the path for the node.js module of the vscode extension. it's strange that re-installing the extension didn't fix it. do you have uncommon vscode configurations, like portable mode, multiple versions, etc?

if re-installing the extension doesn't work, maybe uninstall the extension first and try to download the vsix package and install manually? you can download the package from the marketplace, just make sure to download the correct package for your system(e.g. windows x64):

The binary does not exist at this location.

Tried reinstalling,here's the full error log I got.

2023-08-04 23:00:10.612 [info] ExtensionService#_doActivateExtension rust-lang.rust-analyzer, startup: false, activationEvent: 'onLanguage:rust'
2023-08-04 23:00:10.613 [error] Activating extension rust-lang.rust-analyzer failed due to an error:
2023-08-04 23:00:10.613 [error] Error: Cannot find module 'c:\Users\shred\.vscode\extensions\rust-lang.rust-analyzer-0.3.1607-win32-x64\out\main'
Require stack:
- c:\Users\shred\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js
- c:\Users\shred\AppData\Local\Programs\Microsoft VS Code\resources\app\out\bootstrap-amd.js
- c:\Users\shred\AppData\Local\Programs\Microsoft VS Code\resources\app\out\bootstrap-fork.js
	at Module._resolveFilename (node:internal/modules/cjs/loader:1010:15)
	at s._resolveFilename (node:electron/js2c/utility_init:2:2740)
	at Module._load (node:internal/modules/cjs/loader:858:27)
	at f._load (node:electron/js2c/asar_bundle:2:13330)
	at o._load (c:\Users\shred\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:130:28084)
	at f._load (c:\Users\shred\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:130:25418)
	at C._load (c:\Users\shred\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:94:19511)
	at Module.require (node:internal/modules/cjs/loader:1082:19)
	at require (node:internal/modules/cjs/helpers:102:18)
	at Function.i [as __$__nodeRequire] (c:\Users\shred\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:5:98)
	at r.rb (c:\Users\shred\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\api\node\extensionHostProcess.js:130:26597)
	at async Promise.all (index 0)

How would I manually install the extension?

download the vsix package file from the marketplace webpage, then run this command:

code --install-extension <extension-vsix-path>

but I feel like the real problem is not the rust-analyzer extension, it probably lies somewhere else. just a guess, e.g. your vscode installation might be incomplete, or the extensions database is corrupted.

I suggest you do the following to reinstall vscode cleanly:

  1. backup your user data, default location is "%APPDATA%\Code\User".
  2. uninstall vscode, remove all related program data, default location is "%APPDATA%\Code"
  3. remove the entire extension database, default location is "C:\User<username>.vscode\extensions"
  4. reboot or re-login Windows
  5. reinstall vscode
  6. recover your user data from the backup, like settings.json, keybindings.json, snippets, etc.
  7. launch vscode and install whatever extensions you need

I followed the steps you posted for a clean reinstall,and RustAnalyzer works now. Thanks for the help!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.