fix-python icon indicating copy to clipboard operation
fix-python copied to clipboard

Why is `libs.nix`required to not be in the current working directory?

Open simeoncarstens opened this issue 2 years ago • 1 comments

Title says it all :slightly_smiling_face: If I put my libs.nix into the current working directory, I get

$ fix-python --venv .venv/ --libs libs.nix 
Automatically adding "file" to PATH.
Automatically adding "patchelf" to PATH.
error: undefined variable 'libs'

       at «string»:1:8:

            1| import libs.nix
             |        ^
Failed to load libs from Nix file libs.nix

Try to debug this issue with the command:
    nix build --impure --expr "import libs.nix"

If I move libs.nix anywhere else but the current working directory, everything works fine. This seems like an unnecessary restriction to me, so I'd be curious about the reason for that :thinking:

simeoncarstens avatar Sep 26 '23 15:09 simeoncarstens

Thanks for the report. :+1:

The technical reason is that the path bash variable is used as-is in a Nix expression import $libs_path, and Nix needs at least ./.

So this works:

fix-python --venv .venv/ --libs ./libs.nix

GuillaumeDesforges avatar Sep 26 '23 16:09 GuillaumeDesforges