DeterminateSystems / riff

Riff automatically provides external dependencies for Rust projects, with support for other languages coming soon.
https://riff.sh
Mozilla Public License 2.0
486 stars 13 forks source link

rust-analyzer with VSCode doesn't seem to work with riff shell? #126

Closed xffxff closed 1 year ago

xffxff commented 2 years ago

OS: wsl2 (ubuntu 22.04)

Riff version: 1.0.0

Things I tried to run: riff shell and then open VSCode from the shell

image

it gets an error like

image

I got the same error a few days ago when trying to use nix, which was fixed by adding rust-src to extensions.

{ nixpkgs ? import <nixpkgs> { }}:

let
  rustOverlay = builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz";
  pkgs = import <nixpkgs> {
    overlays = [ (import rustOverlay) ];
  };
in
  pkgs.mkShell {
    buildInputs = with pkgs; [
    (pkgs.rust-bin.stable.latest.default.override {
          extensions = [ "rust-src" "cargo" "rustc" ];
    })
    ];

    RUST_BACKTRACE = 1;
  }
cole-h commented 1 year ago

Could you try my PR at https://github.com/DeterminateSystems/riff/pull/171 and see if this fixes it for you? There are instructions in the PR body, but I'm happy to help further if they are unclear.

If rust-analyzer works for you outside of riff shell, this PR should make it work for you inside as well.

xffxff commented 1 year ago

@cole-h Yes, it works for me. But it uses the rustc I installed on my system, not the nix store.

cole-h commented 1 year ago

That is to be expected. Is this undesirable for you?

The idea is to rely on the user's Rust setup so that any configuration that has been done (e.g. in order to get rust-analyzer working) will be carried over with ease. This also means it's easy to support rust-toolchain.toml files (like in https://github.com/DeterminateSystems/riff/issues/147), because the user-installed rustup will handle that for us.

xffxff commented 1 year ago

This is ok for me. Thanks for the explanation @cole-h , I originally thought that riff wanted to use the rustc installed by nix like other tools like cargo2nix