From 90b81961b8e510b173fd0410f7379eb37b7cf0c1 Mon Sep 17 00:00:00 2001
From: James Porter <james@jamesporter.me>
Date: Sun, 22 Oct 2017 18:46:46 -0400
Subject: [PATCH] fix race condition ??? in eshell path syncing

---
 virtualenvwrapper.el | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/virtualenvwrapper.el b/virtualenvwrapper.el
index dc31e6d..02d6241 100644
--- a/virtualenvwrapper.el
+++ b/virtualenvwrapper.el
@@ -219,9 +219,13 @@ prompting the user with the string PROMPT"
   ;; setup emacs exec-path
   (add-to-list 'exec-path (concat venv-current-dir venv-executables-dir))
   ;; setup the environment for subprocesses
-  (setenv "PATH" (concat venv-current-dir venv-executables-dir path-separator (getenv "PATH")))
-  ;; keep eshell path in sync
-  (setq eshell-path-env (getenv "PATH"))
+  (let ((path (concat venv-current-dir
+               venv-executables-dir
+               path-separator
+               (getenv "PATH"))))
+    (setenv "PATH" path)
+    ;; keep eshell path in sync
+    (setq eshell-path-env path))
   (setenv "VIRTUAL_ENV" venv-current-dir)
   (venv--set-venv-gud-pdb-command-name)
   (run-hooks 'venv-postactivate-hook))