Install rust-analyzer
Purpose and Scope
This page explains how to get rust-analyzer running in an editor by identifying the three pieces the rust-analyzer book treats as prerequisites: the language server binary, an editor that can speak the Language Server Protocol, and the Rust standard library source. The installation path differs depending on whether the editor bundles a server binary. Visual Studio Code users normally receive a bundled copy through the extension, while users of other editors need to install the binary separately and then point the editor integration at it. Sources: src/tools/rust-analyzer/docs/book/src/installation.md, src/tools/rust-analyzer/docs/book/src/rust_analyzer_binary.md
The practical goal is not only to download a file named rust-analyzer. The editor must be able to start that executable, the executable must be compatible with the Rust toolchain used for the project, and the analyzer must be able to inspect the standard library sources so completions, navigation, and diagnostics work inside code that uses Rust library APIs. Most installation failures are therefore environment problems rather than Rust syntax problems: the binary is not visible in the editor environment, the standard library source is absent, or an older overridden toolchain is being used. Sources: src/tools/rust-analyzer/docs/book/src/installation.md, src/tools/rust-analyzer/docs/book/src/rust_analyzer_binary.md
Relevant Source Files
- src/tools/rust-analyzer/docs/book/src/installation.md — defines the top-level installation requirements, the standard-library-source requirement, the VS Code shortcut, the rust-src command, the stable-toolchain compatibility note, the RUSTUP_TOOLCHAIN override pattern, and the crates.io package name for programmatic use.
- src/tools/rust-analyzer/docs/book/src/rust_analyzer_binary.md — documents how editors locate the rust-analyzer executable, how to download and place prebuilt binaries, how to install through rustup, and the platform-specific package-manager notes for Linux, macOS, and Windows.
Core Primitives
The first primitive is the rust-analyzer server binary. It is the executable that an editor launches when it wants semantic Rust language features. The documentation states that text editors require the binary to be in PATH, which means installation is incomplete if the file exists but the editor process cannot find it. The second primitive is an LSP-capable editor or plugin. LSP is the protocol boundary between the editor user interface and rust-analyzer. The third primitive is the standard library source code, which rust-analyzer uses to understand items from core, alloc, and std while analyzing project code. Sources: src/tools/rust-analyzer/docs/book/src/installation.md, src/tools/rust-analyzer/docs/book/src/rust_analyzer_binary.md
These primitives explain why installation guidance is split across two tasks. The installation page starts with the editor-facing prerequisites and tells VS Code users that the extension bundles a binary, while it sends other editor users to the binary installation page and the editor configuration page. The binary page then focuses on how to obtain an executable and put it somewhere discoverable. Treat those as separate checkpoints: first decide whether your editor already provides the server, then confirm the server can run, and finally confirm it can see a supported Rust toolchain and standard library source. Sources: src/tools/rust-analyzer/docs/book/src/installation.md, src/tools/rust-analyzer/docs/book/src/rust_analyzer_binary.md
Installation Paths
The simplest non-VS-Code path is to download a prebuilt binary from the rust-analyzer releases, uncompress it, rename it to the expected executable name, make it executable on Unix-like systems, and move it into a directory listed in PATH. The documentation gives a Linux example that creates a local binary directory, streams the compressed release asset through gunzip, writes the result as the server executable, and marks it executable. The same idea applies elsewhere, but the release asset must match the operating system and CPU architecture rather than blindly using the Linux x86-64 URL. Sources: src/tools/rust-analyzer/docs/book/src/rust_analyzer_binary.md
mkdir -p ~/.local/bin
curl -L https://github.com/rust-lang/rust-analyzer/releases/latest/download/rust-analyzer-x86_64-unknown-linux-gnu.gz | gunzip -c - > ~/.local/bin/rust-analyzer
chmod +x ~/.local/bin/rust-analyzerThe destination directory is intentionally flexible. The book names ~/.local/bin for the Linux example, but it also says other PATH locations such as ~/.cargo/bin or /usr/local/bin work just as well. That detail matters when installing for a graphical editor, because the editor inherits its environment from the way it was launched, not necessarily from the interactive shell where the command succeeded. After installation, verify both the shell path and the editor path. If the editor cannot find the binary even though the shell can, launch the editor from the shell or adjust the desktop entry or environment configuration. Sources: src/tools/rust-analyzer/docs/book/src/rust_analyzer_binary.md
rust-analyzer --versionAnother supported path is rustup. The binary page explicitly says rust-analyzer is available in rustup and gives the component command. This is a good fit when the rest of the Rust toolchain is already managed by rustup, because it keeps the analyzer alongside the installed toolchain components. It does not remove the need for editor configuration: the editor still has to know how to start the server, either by finding it through PATH or by using an extension setting that points to the installed executable. Sources: src/tools/rust-analyzer/docs/book/src/rust_analyzer_binary.md
rustup component add rust-analyzerThe documentation also records platform package-manager routes. Arch Linux users can install a packaged rust-analyzer binary from the repositories or choose the AUR git package, with pacman shown for the repository package. Gentoo users get rust-analyzer through the rust-analyzer USE flag on dev-lang/rust or dev-lang/rust-bin and also need the rust-src USE flag. macOS users can install through Homebrew. Windows users are advised to install the latest Microsoft Visual C++ Redistributable before installation. These routes are equivalent in goal: produce a runnable server binary that the editor can start. Sources: src/tools/rust-analyzer/docs/book/src/rust_analyzer_binary.md
pacman -S rust-analyzer
brew install rust-analyzerStandard Library Source and Toolchain Compatibility
Install or verify the Rust standard library source early, because rust-analyzer needs it for accurate analysis of code that depends on library definitions. The installation page says rust-analyzer will attempt to install the standard library source automatically, but it also gives the manual rustup component command. Manual installation is useful in locked-down environments, when diagnosing missing library items, or when setting up a machine before opening an editor. If rustup manages the toolchain, adding the rust-src component is the canonical local step described by the rust-analyzer book. Sources: src/tools/rust-analyzer/docs/book/src/installation.md
rustup component add rust-srcToolchain compatibility is a common edge case. The installation page states that only the latest stable standard library source is officially supported for use with rust-analyzer. If a project has an override or uses an older toolchain, rust-analyzer may fail to understand Rust source correctly. The prescribed resolutions are to update the toolchain or use an older rust-analyzer version compatible with that toolchain. For projects that keep an override for building but still want the analyzer to use stable, the documented workaround is to set the RUSTUP_TOOLCHAIN environment variable for the server process. Sources: src/tools/rust-analyzer/docs/book/src/installation.md
{ "rust-analyzer.server.extraEnv": { "RUSTUP_TOOLCHAIN": "stable" } }Source Builds and Programmatic Use
Installing from source is available, but the documentation frames it as an alternative rather than the default path. It requires the latest stable Rust toolchain, clones the rust-analyzer repository, and runs the xtask installer for the server. This path is most useful for contributors, people validating local changes, or users who specifically need a build not yet available through a release channel or package manager. For ordinary editor setup, a prebuilt binary, rustup component, or system package is usually simpler and less dependent on the local development environment. Sources: src/tools/rust-analyzer/docs/book/src/rust_analyzer_binary.md
git clone https://github.com/rust-lang/rust-analyzer.git && cd rust-analyzer
cargo xtask install --serverThe installation page also mentions a crates.io package named ra_ap_rust_analyzer for people who want to use rust-analyzer programmatically. That package is a different concern from installing the editor server. An editor integration needs an executable process that implements the language-server behavior, while a programmatic integration may depend on a crate. Keep those workflows separate when debugging: cargo dependency resolution for a Rust crate will not make an editor discover a server binary, and placing a server binary in PATH will not by itself add a Rust library dependency to an application. Sources: src/tools/rust-analyzer/docs/book/src/installation.md
Quick Verification Checklist
After installation, confirm the editor route in the same order rust-analyzer depends on it. First, decide whether the editor bundles the server or expects an external binary. Second, verify that the executable is named rust-analyzer, is executable on Unix-like systems, and is in a directory visible to the editor. Third, install rust-src or confirm that automatic installation succeeded. Fourth, check for rustup overrides that select an older toolchain. Finally, if the shell can run rust-analyzer but the editor cannot, treat PATH inheritance as the likely problem and adjust how the editor process is launched. Sources: src/tools/rust-analyzer/docs/book/src/installation.md, src/tools/rust-analyzer/docs/book/src/rust_analyzer_binary.md
Related Pages
For editor-specific setup, continue to the VS Code and other editors documentation after the binary is installed or confirmed bundled. For configuration, read the rust-analyzer configuration page next, especially if you need to set server environment variables such as RUSTUP_TOOLCHAIN. For feature behavior, diagnostics, and assists, move from installation to the feature documentation only after the server starts successfully. Installation is the foundation: once the editor can launch rust-analyzer and the analyzer can read the standard library source, the rest of the rust-analyzer book explains how to tune the experience for a particular project and editor. Sources: src/tools/rust-analyzer/docs/book/src/installation.md, src/tools/rust-analyzer/docs/book/src/rust_analyzer_binary.md