Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bash environment variable COLUMNS locked in Pipenv shell if exported. #6169

Open
tfpf opened this issue Jun 4, 2024 · 3 comments
Open

Bash environment variable COLUMNS locked in Pipenv shell if exported. #6169

tfpf opened this issue Jun 4, 2024 · 3 comments

Comments

@tfpf
Copy link

tfpf commented Jun 4, 2024

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

  1. Open a terminal (running Bash) in any directory. (No Pipfile is required, since Pipenv creates one.) Ensure that it is running Bash.
  2. Run shopt -s checkwinsize.
  3. Run export COLUMNS.
  4. [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.
  5. Run pipenv shell.
  6. Run shopt -s checkwinsize (just to be sure).
  7. 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

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"
tfpf added a commit to tfpf/WSLNotify that referenced this issue Jun 4, 2024
@oz123
Copy link
Contributor

oz123 commented Jun 12, 2024

This seems like a bug in the underlying shellingham that we (and poetry ) use.

https://github.com/sarugaku/shellingham

@tfpf
Copy link
Author

tfpf commented Jun 20, 2024

@oz123 Would it be possible for you to provide some code showing why that is the case? I can file bug with Shellingham if required.

@oz123
Copy link
Contributor

oz123 commented Jun 20, 2024

Sorry, on a second thought, it's probably not shelling ham. When you run pipenv shell, it's calling shelling ham to detect the shell, and then it calls pexpect.

def fork_compat(self, venv, cwd, args):

This seems to cause the error:

c = pexpect.spawn(self.cmd, ["-i"], dimensions=(dims.lines, dims.columns))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants