diff --git a/news/4615.bugfix.rst b/news/4615.bugfix.rst new file mode 100644 index 0000000000..033e6b4445 --- /dev/null +++ b/news/4615.bugfix.rst @@ -0,0 +1 @@ +Fix bug where environment wouldn't activate in paths containing () and [] symbols diff --git a/pipenv/project.py b/pipenv/project.py index 90ff16fbce..9709609faa 100644 --- a/pipenv/project.py +++ b/pipenv/project.py @@ -395,7 +395,7 @@ def _sanitize(cls, name): # https://www.gnu.org/software/bash/manual/html_node/Double-Quotes.html # http://www.tldp.org/LDP/abs/html/special-chars.html#FIELDREF # https://github.com/torvalds/linux/blob/2bfe01ef/include/uapi/linux/binfmts.h#L18 - return re.sub(r'[ &$`!*@"\\\r\n\t]', "_", name)[0:42] + return re.sub(r'[ &$`!*@"()\[\]\\\r\n\t]', "_", name)[0:42] def _get_virtualenv_hash(self, name): # type: (str) -> str diff --git a/pipenv/shells.py b/pipenv/shells.py index 5a9aae2abc..af3b0c03bf 100644 --- a/pipenv/shells.py +++ b/pipenv/shells.py @@ -50,7 +50,7 @@ def _get_activate_script(cmd, venv): command = "." # Escape any special characters located within the virtualenv path to allow # for proper activation. - venv_location = re.sub(r'([ &$])', r"\\\1", str(venv)) + venv_location = re.sub(r'([ &$()\[\]])', r"\\\1", str(venv)) # The leading space can make history cleaner in some shells. return " {2} {0}/bin/activate{1}".format(venv_location, suffix, command)