rust-overlay icon indicating copy to clipboard operation
rust-overlay copied to clipboard

tries to build within the nix store

Open ofluffydev opened this issue 7 months ago • 1 comments

Pretty clueless on why this happens, it seems to be trying to compile/write to a file in the nix store for some reason

error: could not compile `rustc-std-workspace-core` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: couldn't create a temp dir: Read-only file system (os error 30) at path "/nix/store/cvcxncjfvada7rqqqwfcrmgb79fk1kkn-rust-complete-1.89.0-nightly-2025-05-31/lib/rustlib/src/rust/library/core/rustcouDLci"

my flake:

{
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    rust-overlay.url = "github:oxalica/rust-overlay";
  };

  outputs =
    {
      self,
      nixpkgs,
      rust-overlay,
    }:
    let
      system = "x86_64-linux";
      pkgs = import nixpkgs {
        inherit system;
        overlays = [ rust-overlay.overlays.default ];
      };

      toolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;

      portingMlibcRust = pkgs.rustPlatform.buildRustPackage {
        pname = "portingMlibcRust";
        version = "0.1.0";
        src = self;
        cargoLock.lockFile = ./Cargo.lock;
      };
    in
    {
      devShells.${system}.default = pkgs.mkShell {
        packages = [
          toolchain
          pkgs.rust-analyzer-unwrapped
        ];
        RUST_SRC_PATH = "${toolchain}/lib/rustlib/src/rust/library";
      };

      packages.${system}.default = portingMlibcRust;
    };
}

ofluffydev avatar Jun 01 '25 03:06 ofluffydev

What's the relationship between this issue and rust-overlay? Does it only occur with rust-overlay's toolchain but not the nixpkgs's rustc?

It seems to be an upstream issue: https://github.com/rust-lang/rust-analyzer/pull/20018

oxalica avatar Jun 18 '25 19:06 oxalica

Lol this was closed with no fixes? And I don't honestly know, it looks like it didn't fake the home variables enough or something, causing rust to attempt to cache/do things in the nix store where the actual binary is run. Looking back the issue, it sounds like it may be when recompiling core/std libraries which is common in low level dev

ofluffydev avatar Jun 29 '25 06:06 ofluffydev

Lol this was closed with no fixes?

If you really want it to be fixed, read and answer to my last comment, provide more information about your problematic project (if it's public) and what command you execute to see the error message. The flake does not evaluate on it's own without giving source files of your project.

Ignoring my comment just reduces the chance of it being fixed. You should not be surprised.

oxalica avatar Jun 29 '25 06:06 oxalica

probably the rebuild std flag you can use on nightly, not sure though anymore, I quit using nixos entirely over this.

ofluffydev avatar Jun 29 '25 06:06 ofluffydev