Unable to use rust-analyzer when using vscode's remote ssh extension

I am using VSCode to set-up a remote development environment but Rust Analyzer doesn't seem to work and it's giving this error

Cannot activate rust-analyzer: bootstrap error. See the logs in "OUTPUT > Rust Analyzer Client" (should open automatically). To enable verbose logs use { "rust-analyzer.trace.extension": true }

Even enabling verbose logs gives the same errors.

What is shown there?

INFO [3/10/2021, 4:08:54 PM]: Extension version: 0.4.0-dev
INFO [3/10/2021, 4:08:54 PM]: Using configuration {
  lruCapacity: null,
  files: { watcher: 'client', exclude: [] },
  notifications: { cargoTomlNotFound: true },
  cargo: {
    autoreload: true,
    noDefaultFeatures: false,
    allFeatures: false,
    features: [],
    loadOutDirsFromCheck: false,
    target: null
  },
  rustfmt: { extraArgs: [], overrideCommand: null },
  checkOnSave: {
    enable: true,
    extraArgs: [],
    command: 'check',
    overrideCommand: null,
    allTargets: true,
    noDefaultFeatures: null,
    allFeatures: null,
    features: null
  },
  cargoRunner: null,
  runnableEnv: null,
  inlayHints: {
    enable: true,
    typeHints: true,
    chainingHints: true,
    parameterHints: true,
    maxLength: 20
  },
  completion: {
    addCallParenthesis: true,
    addCallArgumentSnippets: true,
    postfix: { enable: true }
  },
  callInfo: { full: true },
  updates: { channel: 'stable', askBeforeDownload: true },
  serverPath: '/nix/store/d9jpwzir7f196sx0g4m95bp1dcsmz3x1-rust-analyzer-unstable-2020-08-24/bin/rust-analyzer',
  trace: { server: 'off', extension: true },
  procMacro: { enable: false },
  debug: {
    engine: 'auto',
    sourceFileMap: {
      '/rustc/<id>': '${env:USERPROFILE}/.rustup/toolchains/<toolchain-id>/lib/rustlib/src/rust'
    },
    openDebugPane: false,
    engineSettings: {}
  },
  lens: { enable: true, run: true, debug: true, implementations: true },
  hoverActions: {
    enable: true,
    implementations: true,
    run: true,
    debug: true,
    gotoTypeDef: true
  },
  linkedProjects: null,
  withSysroot: true,
  diagnostics: {
    enable: true,
    enableExperimental: true,
    disabled: [],
    warningsAsInfo: [],
    warningsAsHint: []
  }
}
INFO [3/10/2021, 4:08:54 PM]: PersistentState: {
  lastCheck: undefined,
  releaseId: undefined,
  serverVersion: undefined
}
INFO [3/10/2021, 4:08:54 PM]: Using server binary at /nix/store/d9jpwzir7f196sx0g4m95bp1dcsmz3x1-rust-analyzer-unstable-2020-08-24/bin/rust-analyzer
DEBUG [3/10/2021, 4:08:54 PM]: Checking availability of a binary at /nix/store/d9jpwzir7f196sx0g4m95bp1dcsmz3x1-rust-analyzer-unstable-2020-08-24/bin/rust-analyzer
DEBUG [3/10/2021, 4:08:54 PM]: /nix/store/d9jpwzir7f196sx0g4m95bp1dcsmz3x1-rust-analyzer-unstable-2020-08-24/bin/rust-analyzer --version: {
  error: [Error: spawnSync /nix/store/d9jpwzir7f196sx0g4m95bp1dcsmz3x1-rust-analyzer-unstable-2020-08-24/bin/rust-analyzer ENOENT
  	at Object.spawnSync (internal/child_process.js:1041:20)
  	at Object.spawnSync (child_process.js:607:24)
  	at Object.isValidExecutable (/home/humancalico/.vscode-server/extensions/matklad.rust-analyzer-0.4.0-dev/out/src/main.js:12486:51)
  	at bootstrapServer (/home/humancalico/.vscode-server/extensions/matklad.rust-analyzer-0.4.0-dev/out/src/main.js:16183:15)
  	at async bootstrap (/home/humancalico/.vscode-server/extensions/matklad.rust-analyzer-0.4.0-dev/out/src/main.js:16127:18)
  	at async tryActivate (/home/humancalico/.vscode-server/extensions/matklad.rust-analyzer-0.4.0-dev/out/src/main.js:16054:24)
  	at async activate (/home/humancalico/.vscode-server/extensions/matklad.rust-analyzer-0.4.0-dev/out/src/main.js:16028:5)
  	at async Promise.all (index 0)
  	at async Promise.all (index 25)
  	at async Promise.all (index 1)] {
    errno: 'ENOENT',
    code: 'ENOENT',
    syscall: 'spawnSync /nix/store/d9jpwzir7f196sx0g4m95bp1dcsmz3x1-rust-analyzer-unstable-2020-08-24/bin/rust-analyzer',
    path: '/nix/store/d9jpwzir7f196sx0g4m95bp1dcsmz3x1-rust-analyzer-unstable-2020-08-24/bin/rust-analyzer',
    spawnargs: [ '--version' ]
  },
  status: null,
  signal: null,
  output: null,
  pid: 1018684,
  stdout: null,
  stderr: null
}
ERROR [3/10/2021, 4:08:54 PM]: Bootstrap error [Error: Failed to execute /nix/store/d9jpwzir7f196sx0g4m95bp1dcsmz3x1-rust-analyzer-unstable-2020-08-24/bin/rust-analyzer --version
	at bootstrapServer (/home/humancalico/.vscode-server/extensions/matklad.rust-analyzer-0.4.0-dev/out/src/main.js:16184:15)
	at async bootstrap (/home/humancalico/.vscode-server/extensions/matklad.rust-analyzer-0.4.0-dev/out/src/main.js:16127:18)
	at async tryActivate (/home/humancalico/.vscode-server/extensions/matklad.rust-analyzer-0.4.0-dev/out/src/main.js:16054:24)
	at async activate (/home/humancalico/.vscode-server/extensions/matklad.rust-analyzer-0.4.0-dev/out/src/main.js:16028:5)
	at async Promise.all (index 0)
	at async Promise.all (index 25)
	at async Promise.all (index 1)]

On the remote server, what do you get if you run (thats what it looks like its trying to do and is failing to run).

/nix/store/d9jpwzir7f196sx0g4m95bp1dcsmz3x1-rust-analyzer-unstable-2020-08-24/bin/rust-analyzer --version

Generally though it seems like its trying to use the preinstalled version of rust-analyzer on the remote server. It might be easier to uninstall that (nix-env -e rust-analyzer) and let vscode download the binary itself, which it should do.

On the remote server, what do you get if you run (thats what it looks like its trying to do and is failing to run).

Hmm it seems like there is no path similar to that on the remote server but it's on the local system.

I'm guessing then that maybe you have a global setting for a path to rust-analyzer or something that vscode is picking up and trying to use on the remote machine. I'm guessing that if this isn't something you did, its done automatically by some nix definition for rust-analyzer. If it were me, i would just remove the rust-analyzer install from nix locally and then just install the extension through vscode which will then automatically download the latest version of the rust-analyzer binary.

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.