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

Flake nix shells: Build fails when working directory path contains spaces #12413

Open
2 tasks done
FreaxMATE opened this issue Feb 3, 2025 · 0 comments
Open
2 tasks done
Labels

Comments

@FreaxMATE
Copy link

FreaxMATE commented Feb 3, 2025

Describe the bug

Compilation of a c/c++ file fails in flake-based nix shell development environment when directory name contains spaces.

Steps To Reproduce

  1. Create sample flake.nix and main.c in directory TestDir
    flake.nix
{
  description = "Test";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
  };

  outputs = { self , nixpkgs ,... }:
  let
    system = "x86_64-linux";
  in {
    devShells."${system}".default =
    let
      pkgs = import nixpkgs {
        inherit system;
      };
    in pkgs.mkShell {
      packages = with pkgs; [
        gcc
      ];
    };
  };
}

main.c

#include <stdio.h>

int main(int argc, char**argv)
{
    printf("Hello world!");
    return 0;
}
  1. Run nix develop
  2. Compile the project using gcc main.c. This should run without issues
  3. Now rename the parent directory name to Test Dir and run steps 2. and 3. again. This failed with:
/nix/store/vk4mlknqk9yjbqa68a7rvpfxfdw3rad7-binutils-2.43.1/bin/ld: cannot find Dir/outputs/out/lib: No such file or directory
collect2: error: ld returned 1 exit status

Expected behavior

Compilation should succeed without any error.

Metadata

<!-- Please insert the output of running nix-env --version` below this line -->
nix-env (Nix) 2.24.12

Additional context

Similar issue: #7707

Checklist


Add 👍 to issues you find important.

@FreaxMATE FreaxMATE added the bug label Feb 3, 2025
@FreaxMATE FreaxMATE changed the title Flake nix shells: Build fails on filepaths containing spaces Flake nix shells: Build fails when working directory path contains spaces Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant