rust-lang / rust-lang/rust-analyzer

RA does not work at all when offline

Open
#12,499 34 comments 13 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-cargo C-support
Dominant language
Rust
Stars
16.9k
Forks
2.2k
Avg merge
1d 12h
Merged PRs (30d)
72

Description

I tried to do a bit of coding on rustc while on a plane without internet, and noticed that RA handles this situation quite badly. cargo metadata fails because it cannot refresh the index, and then basically nothing works, even though everything needed should be available offline. In particular, not even "check on save" does anything -- I had to run ./x.py check by hand. That worked perfectly fine, demonstrating that RA could also have run x.py as usual and show the diagnostics in the editor.

rust-analyzer version: ad6810e90 2022-06-06 stable

rustc version: rustc 1.63.0-nightly (e09449220 2022-05-31)

relevant settings:

{
    "rust-analyzer.checkOnSave.enable": true,
    "rust-analyzer.checkOnSave.overrideCommand": [
        "./x.py",
        "check",
        "--json-output",
        "library/std",
        "compiler/rustc",
    ],
    "rust-analyzer.rustfmt.overrideCommand": [
        "./build/x86_64-unknown-linux-gnu/stage0/bin/rustfmt",
        "--edition=2021"
    ],
    "rust-analyzer.procMacro.enable": false,
    "editor.formatOnSave": false,
    "files.watcherExclude": {
        "*rustc*/src/llvm-project/**": true,
        "*rustc*/build/**": true,
    },
    "files.exclude": {
        "src/llvm-project/**": true,
        "build/**": true
    },
    "rust-analyzer.cargo.buildScripts.enable": false,
    "rust-analyzer.rustc.source": "./Cargo.toml",
    "rust-analyzer.hover.actions.references.enable": true,
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the offline setup using the listed rust-analyzer settings, especially the ./x.py check override and ./Cargo.toml source, then trace the cargo metadata and check-on-save paths. Confirm the behavior against ./x.py check; done means rust-analyzer can run the configured check command and display diagnostics while offline.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, developer-experience, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.