You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
pipenv run cd
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].
This bug can be circumvented by either writing a bash script with the desired command and executing that from pipenv run, or by making a proxy file in the PATH that calls the desired shell built-in.
e.g. for cd
cd$@
Both are valid workarounds, but both require additional files written on my system.
On further testing, this does NOT evade the issue for more complex issues, as the $@ takes any other commands put after the cd command and errors from passing too many args to cd. :(
And the cd wouldn't actually change the directory properly with a proxy file, as a new shell would be created, so the pipenv virtual environment wouldn't actually change the directory.
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 fromwhich <command>
.A simple example of this bug would be:
pipenv run cd
which will fail with
The issue appears to be that in
do_run_posix
inpipenv/pipenv/routines/shell.py
the 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 cd
to 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:
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'):The text was updated successfully, but these errors were encountered: