Issue description
When running pipenv in Ubuntu 22.04.4 LTS on Windows 10 x86_64 using WSL2, pipenv run fails to execute built-in commands that don't provide a path from which <command>.
A simple example of this bug would be:
which will fail with
Error: the command cd could not be found within PATH or Pipfile's [scripts].
The issue appears to be that in do_run_posix in pipenv/pipenv/routines/shell.py the first thing we try to do is to get a command path by expanding the first command with which. For shell builtins such as cd, there is no expansion that can be found with which, leading to the error logged above.
Since pipenv uses the host shell I don't think there is a reason we shouldn't accept leading builtin commands.
Expected result
If running a Ubuntu shell, I'd expect pipenv run cd to start a new shell with the virtual environment, run the cd command, and exit without output.
Actual result
$ cd
Error: the command cd could not be found within PATH or Pipfile's [scripts].
Steps to replicate
- fresh install of ubuntu.
- pipenv --python 3.11
- run
pipenv run cd
$ pipenv --support
Pipenv version: '2024.0.1'
Pipenv location: '/home/johnstonem/.local/lib/python3.11/site-packages/pipenv'
Python location: '/home/johnstonem/.pyenv/versions/3.11.9/bin/python3.11'
OS Name: 'posix'
User pip version: '24.0'
user Python installations found:
PEP 508 Information:
{'implementation_name': 'cpython',
'implementation_version': '3.11.9',
'os_name': 'posix',
'platform_machine': 'x86_64',
'platform_python_implementation': 'CPython',
'platform_release': '5.15.153.1-microsoft-standard-WSL2',
'platform_system': 'Linux',
'platform_version': '#1 SMP Fri Mar 29 23:14:13 UTC 2024',
'python_full_version': '3.11.9',
'python_version': '3.11',
'sys_platform': 'linux'}
System environment variables:
SHELL
WSL2_GUI_APPS_ENABLED
TERM_PROGRAM_VERSION
WSL_DISTRO_NAME
TMUX
WT_SESSION
TMUX_PLUGIN_MANAGER_PATH
NAME
PWD
LOGNAME
HOME
LANG
WSL_INTEROP
LS_COLORS
WAYLAND_DISPLAY
LESSCLOSE
TERM
LESSOPEN
USER
TMUX_PANE
DISPLAY
SHLVL
XDG_RUNTIME_DIR
PYENV_ROOT
WSLENV
XDG_DATA_DIRS
BROWSER
PATH
DBUS_SESSION_BUS_ADDRESS
HOSTTYPE
PULSE_SERVER
WT_PROFILE_ID
OLDPWD
TERM_PROGRAM
_
PIP_DISABLE_PIP_VERSION_CHECK
PYTHONDONTWRITEBYTECODE
PYTHONFINDER_IGNORE_UNSUPPORTED
PipenvΓÇôspecific environment variables:
DebugΓÇôspecific environment variables:
PATH: /home/johnstonem/.pyenv/versions/3.11.9/bin:/usr/bin:/home/johnstonem/.pyenv/versions/3.11.9/bin:/home/johnstonem/.pyenv/bin:/home/johnstonem/.local/bin:/usr/bin:/home/johnstonem/.pyenv/versions/3.11.9/bin:/home/johnstonem/.pyenv/bin:/home/johnstonem/.local/bin:/usr/bin:/home/johnstonem/.pyenv/versions/3.11.9/bin:/home/johnstonem/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/WINDOWS/CCM/:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/system32/config/systemprofile/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files (x86)/Microsoft SQL Server/160/DTS/Binn/:/mnt/c/Program Files/Azure Data Studio/bin:/mnt/c/Program Files/PuTTY/:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/Users/mitchelj/AppData/Local/Programs/Python/Python311/Scripts/:/mnt/c/Users/mitchelj/AppData/Local/Programs/Python/Python311/:/mnt/c/Users/mitchelj/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/mitchelj/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Program Files/R/R-4.3.1/bin:/mnt/c/Program Files (x86)/GnuWin32/bin:/snap/bin:/opt/mssql-tools18/bin:/opt/mssql-tools18/bin:/opt/mssql-tools18/bin
SHELL: /bin/bash
LANG: C.UTF-8
PWD: /mnt/c/test
Contents of Pipfile ('/mnt/c/test/Pipfile'):
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
[dev-packages]
[requires]
python_version = "3.11"
python_full_version = "3.11.9"
Issue description
When running pipenv in Ubuntu 22.04.4 LTS on Windows 10 x86_64 using WSL2,
pipenv runfails to execute built-in commands that don't provide a path fromwhich <command>.A simple example of this bug would be:
pipenv run cdwhich will fail with
The issue appears to be that in
do_run_posixinpipenv/pipenv/routines/shell.pythe first thing we try to do is to get a command path by expanding the first command withwhich. For shell builtins such ascd, there is no expansion that can be found withwhich, leading to the error logged above.Since pipenv uses the host shell I don't think there is a reason we shouldn't accept leading builtin commands.
Expected result
If running a Ubuntu shell, I'd expect
pipenv run cdto start a new shell with the virtual environment, run the cd command, and exit without output.Actual result
Steps to replicate
pipenv run cd$ pipenv --support
Pipenv version:
'2024.0.1'Pipenv location:
'/home/johnstonem/.local/lib/python3.11/site-packages/pipenv'Python location:
'/home/johnstonem/.pyenv/versions/3.11.9/bin/python3.11'OS Name:
'posix'User pip version:
'24.0'user Python installations found:
PEP 508 Information:
System environment variables:
SHELLWSL2_GUI_APPS_ENABLEDTERM_PROGRAM_VERSIONWSL_DISTRO_NAMETMUXWT_SESSIONTMUX_PLUGIN_MANAGER_PATHNAMEPWDLOGNAMEHOMELANGWSL_INTEROPLS_COLORSWAYLAND_DISPLAYLESSCLOSETERMLESSOPENUSERTMUX_PANEDISPLAYSHLVLXDG_RUNTIME_DIRPYENV_ROOTWSLENVXDG_DATA_DIRSBROWSERPATHDBUS_SESSION_BUS_ADDRESSHOSTTYPEPULSE_SERVERWT_PROFILE_IDOLDPWDTERM_PROGRAM_PIP_DISABLE_PIP_VERSION_CHECKPYTHONDONTWRITEBYTECODEPYTHONFINDER_IGNORE_UNSUPPORTEDPipenvΓÇôspecific environment variables:
DebugΓÇôspecific environment variables:
PATH:/home/johnstonem/.pyenv/versions/3.11.9/bin:/usr/bin:/home/johnstonem/.pyenv/versions/3.11.9/bin:/home/johnstonem/.pyenv/bin:/home/johnstonem/.local/bin:/usr/bin:/home/johnstonem/.pyenv/versions/3.11.9/bin:/home/johnstonem/.pyenv/bin:/home/johnstonem/.local/bin:/usr/bin:/home/johnstonem/.pyenv/versions/3.11.9/bin:/home/johnstonem/.pyenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/WINDOWS/CCM/:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/system32/config/systemprofile/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files/Git/cmd:/mnt/c/Program Files (x86)/Microsoft SQL Server/160/DTS/Binn/:/mnt/c/Program Files/Azure Data Studio/bin:/mnt/c/Program Files/PuTTY/:/mnt/c/Program Files/Docker/Docker/resources/bin:/mnt/c/Users/mitchelj/AppData/Local/Programs/Python/Python311/Scripts/:/mnt/c/Users/mitchelj/AppData/Local/Programs/Python/Python311/:/mnt/c/Users/mitchelj/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/mitchelj/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Program Files/R/R-4.3.1/bin:/mnt/c/Program Files (x86)/GnuWin32/bin:/snap/bin:/opt/mssql-tools18/bin:/opt/mssql-tools18/bin:/opt/mssql-tools18/binSHELL:/bin/bashLANG:C.UTF-8PWD:/mnt/c/testContents of
Pipfile('/mnt/c/test/Pipfile'):