Open dotysan opened 1 year ago
I'm not familiar enough with this project to know if this is a bug or a regression.
I can't think of a reason that NODE_VIRTUAL_ENV isn't already in the PATH. So the quick and brutal fix is this.
diff --git a/nodeenv.py b/nodeenv.py
index 5c8aa2e..70bd577 100644
--- a/nodeenv.py
+++ b/nodeenv.py
@@ -1338,7 +1338,7 @@ fi
export NODE_VIRTUAL_ENV
_OLD_NODE_VIRTUAL_PATH="$PATH"
-PATH="$NODE_VIRTUAL_ENV/lib/node_modules/.bin:$NODE_VIRTUAL_ENV/__BIN_NAME__:$PATH"
+PATH="$NODE_VIRTUAL_ENV/lib/node_modules/.bin:$PATH"
export PATH
_OLD_NODE_PATH="$NODE_PATH"
However, out of the abundance of caution, if there ever is a reason that the NODE_VIRTUAL_ENV would be missing from the PATH, then here's a more spaghettified patch.
diff --git a/nodeenv.py b/nodeenv.py
index 5c8aa2e..23ed41f 100644
--- a/nodeenv.py
+++ b/nodeenv.py
@@ -1338,7 +1338,10 @@ fi
export NODE_VIRTUAL_ENV
_OLD_NODE_VIRTUAL_PATH="$PATH"
-PATH="$NODE_VIRTUAL_ENV/lib/node_modules/.bin:$NODE_VIRTUAL_ENV/__BIN_NAME__:$PATH"
+if [[ $PATH != *$NODE_VIRTUAL_ENV/__BIN_NAME__* ]]
+then PATH="$NODE_VIRTUAL_ENV/__BIN_NAME__:$PATH"
+fi
+PATH="$NODE_VIRTUAL_ENV/lib/node_modules/.bin:$PATH"
export PATH
_OLD_NODE_PATH="$NODE_PATH"
Or this variant:
diff --git a/nodeenv.py b/nodeenv.py
index 5c8aa2e..229efc2 100644
--- a/nodeenv.py
+++ b/nodeenv.py
@@ -1338,7 +1338,9 @@ fi
export NODE_VIRTUAL_ENV
_OLD_NODE_VIRTUAL_PATH="$PATH"
-PATH="$NODE_VIRTUAL_ENV/lib/node_modules/.bin:$NODE_VIRTUAL_ENV/__BIN_NAME__:$PATH"
+[[ $PATH = *$NODE_VIRTUAL_ENV/__BIN_NAME__* ]] \
+ || PATH="$NODE_VIRTUAL_ENV/__BIN_NAME__:$PATH"
+PATH="$NODE_VIRTUAL_ENV/lib/node_modules/.bin:$PATH"
export PATH
_OLD_NODE_PATH="$NODE_PATH"
Thoughts?
This is bash only. I still haven't looked at csh/fish/ps implementations of activate. But if logic is sound, happy to generate a PR and start working on those too.
When installed into a running python3 venv, that path is duplicated. Fairly easy to reproduce.
Notice that PATH is already prepended with the
.venv/bin
.Then install nodeenv inside that active venv.
The next time you re-activate...
...that path is duplicated.