From 924af5d87343b12d26f9aac40007edaabf73c7fe Mon Sep 17 00:00:00 2001 From: Thomas Schneider Date: Wed, 14 Aug 2024 17:31:52 +0200 Subject: [PATCH] pipenv: Ignore additional pipenv output Pipenv can print additional output that would end up in our variables, e. g., if a `.env` file exists, `python-shell-virtualenv-root` ends up as `Loading .env environment variables...\n/home/user/.local/share/virtualenvs/project`. This change is to: a) call pipenv with `--quiet`, so that it does not print extra information in the first place; b) pass `'(t nil)` as `buffer` argument to `process-file`, so that it ignores stderr and the buffer only contains stdout. Signed-off-by: Thomas Schneider --- pet.el | 2 +- test/pet-test.el | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pet.el b/pet.el index 3ffb473..81d8570 100644 --- a/pet.el +++ b/pet.el @@ -633,7 +633,7 @@ Selects a virtualenv in the follow order: (default-directory (file-name-directory (pet-pipfile-path)))) (condition-case err (with-temp-buffer - (let ((exit-code (process-file program nil t nil "--venv")) + (let ((exit-code (process-file program nil '(t nil) nil "--quiet" "--venv")) (output (string-trim (buffer-string)))) (if (zerop exit-code) output diff --git a/test/pet-test.el b/test/pet-test.el index 376c312..ab61ec6 100644 --- a/test/pet-test.el +++ b/test/pet-test.el @@ -790,7 +790,7 @@ (spy-on 'call-process :and-call-fake (lambda (&rest _) (insert pipenv-virtualenv) 0)) (expect (pet-virtualenv-root) :to-equal pipenv-virtualenv) (expect (assoc-default project-root pet-project-virtualenv-cache) :to-equal pipenv-virtualenv) - (expect 'call-process :to-have-been-called-with pipenv-path nil t nil "--venv")) + (expect 'call-process :to-have-been-called-with pipenv-path nil '(t nil) nil "--quiet" "--venv")) (it "should return the absolute path of the `.venv' or `venv' directory in a project" (spy-on 'pet-use-conda-p :and-return-value nil)