From ccaa642d988b78211a6917297f13d3323b4bb335 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Fri, 21 Sep 2018 13:31:46 -0400 Subject: [PATCH] lang/python: fix pipenv creating Pipfiles in pwd #888 `pipenv run ...` searches for a Pipfile itself, but doesn't search far enough, creating a Pipfile in the current directory. Instead, we run the command from the pipenv project root so it doesn't have to search. --- modules/lang/python/autoload/python.el | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/lang/python/autoload/python.el b/modules/lang/python/autoload/python.el index 4f4030763..ecca5a796 100644 --- a/modules/lang/python/autoload/python.el +++ b/modules/lang/python/autoload/python.el @@ -14,7 +14,9 @@ the current pipenv. This is not necessarily aware of env management tools like virtualenv, pyenv or pipenv, unless those tools have modified the PATH that Emacs picked up when you started it." - (let* ((command (if (pipenv-project-p) + (let* ((pipenv-dir (pipenv-project-p)) + (default-directory (or pipenv-dir default-directory)) + (command (if pipenv-dir "pipenv run python --version" "python --version")) (bin (car (split-string command " ")))) @@ -26,4 +28,4 @@ started it." (output (string-trim (buffer-string)))) (unless (zerop p) (user-error "'%s' failed: %s" command output)) - (nth 1 (split-string output " " t)))))) + (cadr (split-string output " " t))))))