nix-community / fenix

Rust toolchains and rust-analyzer nightly for Nix [maintainer=@figsoda]
Mozilla Public License 2.0
670 stars 42 forks source link

Failed to open metadata error #169

Open prescientmoon opened 1 week ago

prescientmoon commented 1 week ago

I have the following flake

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/release-24.05";
    flake-utils.url = "github:numtide/flake-utils";
    fenix.url = "github:nix-community/fenix";
    fenix.inputs.nixpkgs.follows = "nixpkgs";
  };

  outputs =
    { ... }@inputs:
    inputs.flake-utils.lib.eachSystem (with inputs.flake-utils.lib.system; [ x86_64-linux ]) (
      system:
      let
        pkgs = inputs.nixpkgs.legacyPackages.${system}.extend inputs.fenix.overlays.default;
        inherit (pkgs) lib;
      in
      {
        devShell = pkgs.mkShell rec {
          packages = with pkgs; [
            (fenix.complete.withComponents [
              "cargo"
              "clippy"
              "rust-src"
              "rustc"
              "rustfmt"
              "rust-analyzer"
            ])
            ruff
            imagemagick
            fontconfig
            freetype

            clang
            llvmPackages.clang
            pkg-config

            leptonica
            tesseract
            openssl
            sqlite
          ];

          LD_LIBRARY_PATH = lib.makeLibraryPath packages;
          LIBCLANG_PATH = "${pkgs.llvmPackages.libclang.lib}/lib";
        };
      }
    );
}

Trying to run cargo check --all-targets on a project split into a lib and a bunch of binaries yields errors like failed to open rmeta metadata: '/home/.../projects/.../target/debug/deps/libtoml_edit-966d927d27fec036.rmeta'. This looks like the same issue as this crane FAQ entry, although I'm installing all the things together, so I'm confused as to why it happens.

prescientmoon commented 1 week ago

I have narrowed it down to it only happening when both --bin and --lib are passed at the same time. Still haven't found a fix.