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

Unable to use pythonPackages.venvShellHook #75

Open
sephii opened this issue Jan 20, 2022 · 0 comments
Open

Unable to use pythonPackages.venvShellHook #75

sephii opened this issue Jan 20, 2022 · 0 comments

Comments

@sephii
Copy link

sephii commented Jan 20, 2022

Describe the bug

Using lorri with pythonPackages.venvShellHook as mentioned in the nixpkgs docs results in an error.

To Reproduce

Create a shell.nix file with the following contents:

{ pkgs ? import (builtins.fetchGit {
    url = "https://github.com/NixOS/nixpkgs";
    ref = "nixos-21.11";
    rev = "77aa71f66fd05d9e7b7d1c084865d703a8008ab7";
  }) { } }:
let
  pythonPackages = pkgs.python38Packages;
in pkgs.mkShell {
  name = "impurePythonEnv";

  buildInputs = [
    pythonPackages.venvShellHook
    pythonPackages.wheel
  ];

  venvDir = "./.venv";

  postVenvCreation = ''
    unset SOURCE_DATE_EPOCH
    pip install -r ./requirements.txt
  '';

  postShellHook = ''
    # allow pip to install wheels
    unset SOURCE_DATE_EPOCH
  '';
}

Put something in requirements.txt like django, and then run lorri shell. You’ll get the following error:

lorri shell
lorri: building environment.......... done
Jan 20 09:34:46.604 ERRO Build failed. No cached environment available.
Build error: Nix process returned exit code 1.
$ "nix-build" "--out-link" "/tmp/.tmpoM4Zgu/result" "--" "/tmp/.tmpzQiyBN/result"
this derivation will be built:
  /nix/store/3jdfxdmqzrg9f17nv384vyf8r5x3r18a-lorri-keep-env-hack-impurePythonEnv.drv
building '/nix/store/3jdfxdmqzrg9f17nv384vyf8r5x3r18a-lorri-keep-env-hack-impurePythonEnv.drv'...
Using venvShellHook
Executing venvHook
Creating new venv environment in path: './.venv'
WARNING: The directory '/homeless-shelter/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
ERROR: Could not open requirements file: [Errno 2] No such file or directory: './requirements.txt'
error: builder for '/nix/store/3jdfxdmqzrg9f17nv384vyf8r5x3r18a-lorri-keep-env-hack-impurePythonEnv.drv' failed with exit code 1;
       last 5 log lines:
       > Using venvShellHook
       > Executing venvHook
       > Creating new venv environment in path: './.venv'
       > WARNING: The directory '/homeless-shelter/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag.
       > ERROR: Could not open requirements file: [Errno 2] No such file or directory: './requirements.txt'
       For full logs, run 'nix log /nix/store/3jdfxdmqzrg9f17nv384vyf8r5x3r18a-lorri-keep-env-hack-impurePythonEnv.drv'.

Expected behavior
The Python virtual environment is created and activated.

Metadata

lorri info --shell-file shell.nix
lorri version: 1.5uname -a
Linux midgar 5.10.81 #1-NixOS SMP Sun Nov 21 12:46:37 UTC 2021 x86_64 GNU/Linux
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