Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust-analyzer doesn't find std from another arch #188

Open
Libadoxon opened this issue Dec 15, 2024 · 0 comments
Open

rust-analyzer doesn't find std from another arch #188

Libadoxon opened this issue Dec 15, 2024 · 0 comments

Comments

@Libadoxon
Copy link

I currently have the flake:

{
  inputs = {
    flake-utils.url = "github:numtide/flake-utils";
    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
    fenix.url = "github:nix-community/fenix";
    naersk.url = "github:nix-community/naersk";
  };

  outputs =
    {
      self,
      flake-utils,
      nixpkgs,
      fenix,
      naersk,
    }:
    flake-utils.lib.eachDefaultSystem (
      system:
      let
        pkgs = (import nixpkgs) {
          inherit system;
        };

        toolchain =
          with fenix.packages.${system};
          combine [
            minimal.rustc
            minimal.cargo
            targets.x86_64-pc-windows-gnu.latest.rust-std
          ];

        naersk' = naersk.lib.${system}.override {
          cargo = toolchain;
          rustc = toolchain;
        };
      in
      rec {
        devShell = pkgs.mkShell {
          nativeBuildInputs = [ toolchain pkgs.rust-analyzer ];
        };

        defaultPackage = packages.print-guid;
        packages.print-guid = naersk'.buildPackage {
          src = ./.;
          strictDeps = true;

          depsBuildBuild = with pkgs; [
            pkgsCross.mingwW64.stdenv.cc
            pkgsCross.mingwW64.windows.pthreads
          ];
        };
      }
    );
}

I have set my .cargo/config.toml to

[build]
target = "x86_64-pc-windows-gnu"

When running cargo build everything builds fine but in nvim I get the rust-analyzer error:

can't find crate for `std` the `x86_64-pc-windows-gnu` target may not be installed consider downloading the target with `rustup target add x86_64-pc-windows-gnu` [E0463]

How to make rust-analyzer find the std crate for the specified arch?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant