pipenv
pipenv copied to clipboard
Bash environment variable `COLUMNS` locked in Pipenv shell if exported.
Issue description
If COLUMNS
is exported prior to starting a Pipenv shell in Bash, it does not get updated upon resizing the terminal window, even if the checkwinsize
Bash setting is enabled.
Expected result
If the terminal window is resized, COLUMNS
should get updated, irrespective of whether Bash is running in a normal shell or a Pipenv shell, or if it has been exported.
Actual result
COLUMNS
does not get updated in a Pipenv shell if it has been exported.
Steps to replicate
- Open a terminal (running Bash) in any directory. (No
Pipfile
is required, since Pipenv creates one.) Ensure that it is running Bash. - Run
shopt -s checkwinsize
. - Run
export COLUMNS
. - [optional] Resize the terminal window and run
echo $COLUMNS
. Repeat a couple of times. The output of the command reflects the width of the terminal. - Run
pipenv shell
. - Run
shopt -s checkwinsize
(just to be sure). - Resize the terminal window and run
echo $COLUMNS
. Repeat a couple of times. The output of the command does not reflect the width of the terminal; it remains fixed.
Additional Information
In step 5, instead of running pipenv shell
, if I:
- run
bash
, or - load the virtual environment manually by running
. ~/.local/share/virtualenvs/path-to-venv/bin/activate
,
then there is no issue: COLUMNS
gets updated as expected. Which leads me to believe this is a Pipenv issue. I cleared ~/.bashrc
prior to executing all of the above steps. I am using GNU bash, version 5.2.26(1)-release (x86_64-pc-linux-gnu).
See also
- https://github.com/python-poetry/poetry/issues/4121
- https://github.com/python-poetry/poetry/issues/4165
- https://github.com/python-poetry/poetry/issues/6351
which discuss the same issue with Poetry. They mention this is not observed with Pipenv; however, if COLUMNS
is exported, Pipenv suffers from the same problem.
$ pipenv --support
Pipenv version: '2023.12.1'
Pipenv location: '/usr/lib/python3.12/site-packages/pipenv'
Python location: '/usr/bin/python'
OS Name: 'posix'
User pip version: '23.3.2'
user Python installations found:
PEP 508 Information:
{'implementation_name': 'cpython',
'implementation_version': '3.12.3',
'os_name': 'posix',
'platform_machine': 'x86_64',
'platform_python_implementation': 'CPython',
'platform_release': '6.6.32-1-lts',
'platform_system': 'Linux',
'platform_version': '#1 SMP PREEMPT_DYNAMIC Sat, 25 May 2024 20:20:51 +0000',
'python_full_version': '3.12.3',
'python_version': '3.12',
'sys_platform': 'linux'}
System environment variables:
-
SHELL
-
SESSION_MANAGER
-
WINDOWID
-
COLORTERM
-
XDG_SESSION_PATH
-
GNOME_DESKTOP_SESSION_ID
-
LC_ADDRESS
-
LC_NAME
-
CINNAMON_VERSION
-
DESKTOP_SESSION
-
LC_MONETARY
-
GTK_MODULES
-
XDG_SEAT
-
PWD
-
LOGNAME
-
XDG_SESSION_DESKTOP
-
QT_QPA_PLATFORMTHEME
-
XDG_SESSION_TYPE
-
XAUTHORITY
-
XDG_GREETER_DATA_DIR
-
GJS_DEBUG_TOPICS
-
MOTD_SHOWN
-
HOME
-
LC_PAPER
-
LANG
-
XDG_CURRENT_DESKTOP
-
VTE_VERSION
-
XDG_SEAT_PATH
-
GJS_DEBUG_OUTPUT
-
XDG_SESSION_CLASS
-
TERM
-
LC_IDENTIFICATION
-
USER
-
DISPLAY
-
SHLVL
-
LC_TELEPHONE
-
LC_MEASUREMENT
-
XDG_VTNR
-
XDG_SESSION_ID
-
XDG_RUNTIME_DIR
-
DEBUGINFOD_URLS
-
LC_TIME
-
GTK3_MODULES
-
PATH
-
GDMSESSION
-
DBUS_SESSION_BUS_ADDRESS
-
MAIL
-
GIO_LAUNCHED_DESKTOP_FILE_PID
-
GIO_LAUNCHED_DESKTOP_FILE
-
LC_NUMERIC
-
_
-
PIP_DISABLE_PIP_VERSION_CHECK
-
PYTHONDONTWRITEBYTECODE
-
PYTHONFINDER_IGNORE_UNSUPPORTED
Pipenv–specific environment variables:
Debug–specific environment variables:
-
PATH
:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
-
SHELL
:/bin/bash
-
LANG
:en_GB.UTF-8
-
PWD
:/home/tfpf/Documents/projects/pipenv-bug
Contents of Pipfile
('/home/tfpf/Documents/projects/pipenv-bug/Pipfile'):
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
[dev-packages]
[requires]
python_version = "3.12"