pipenv icon indicating copy to clipboard operation
pipenv copied to clipboard

Fix pipenv shell --quiet to actually suppress output

Open matteius opened this issue 4 weeks ago • 0 comments

Summary

Fixes #5954

The --quiet flag and PIPENV_QUIET environment variable now properly suppress all shell activation output.

Problem

When running pipenv shell, users see 3 lines of output:

❯ pipenv shell
Launching subshell in virtual environment...
 . /home/user/.local/share/virtualenvs/project-xxxx/bin/activate
❯  . /home/user/.local/share/virtualenvs/project-xxxx/bin/activate

The --quiet flag was documented but didn't fully suppress the output - specifically, it didn't suppress the activation command echo in pexpect-based compat mode.

Solution

  1. Pass quiet parameter to fork_compat(): The shell's compat mode now receives the quiet setting.

  2. Use setecho(False) in quiet mode: When quiet mode is enabled, the pexpect session disables echo before sending the activation command, then re-enables it after. This prevents the activation command from being displayed.

  3. Respect PIPENV_QUIET environment variable: The shell command now checks project.s.is_quiet() in addition to the --quiet flag, so users can set PIPENV_QUIET=1 globally.

Usage

# Using the --quiet flag
$ pipenv shell --quiet

# Using the environment variable
$ export PIPENV_QUIET=1
$ pipenv shell

Changes

  • pipenv/shells.py: Added quiet parameter to fork_compat(), uses setecho(False) to suppress activation command output
  • pipenv/routines/shell.py: Pass quiet to fork_compat(), also respect PIPENV_QUIET environment variable via project.s.is_quiet()

Pull Request opened by Augment Code with guidance from the PR author

matteius avatar Dec 10 '25 23:12 matteius