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

Is there a way to disable / suppress pipenv's "Courtesy Notice" about virtual environments? #2527

Closed
trianta2 opened this Issue Jul 5, 2018 · 7 comments

Comments

Projects
None yet
4 participants
@trianta2

trianta2 commented Jul 5, 2018

Each time I invoke pipenv I see:

Courtesy Notice: Pipenv found itself running within a virtual environment, so it will automatically use that environment, instead of creating its own for any project. You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead.

Can this be globally suppressed?

@uranusjr

This comment has been minimized.

Member

uranusjr commented Jul 5, 2018

No, there is not.

@uranusjr uranusjr closed this Jul 5, 2018

@uranusjr

This comment has been minimized.

Member

uranusjr commented Jul 5, 2018

That said, maybe we can treat an empty PIPENV_IGNORE_VIRTUALENVS as the suppressor.

  • PIPENV_IGNORE_VIRTUALENVS absent—show the message.
  • PIPENV_IGNORE_VIRTUALENVS set to empty string—suppress the message, but use the environment.
  • PIPENV_IGNORE_VIRTUALENVS is not empty—create a nested virtualenv.
@trianta2

This comment has been minimized.

trianta2 commented Jul 5, 2018

Does PIPENV_IGNORE_VIRTUALENVS=0 have any significance? If pipenv was told to not ignore virtual envs, then that should mean I want to use my existing virtual env, and the courtesy notice should be suppressed.

@techalchemy

This comment has been minimized.

Member

techalchemy commented Jul 5, 2018

We have an environment variable to suppress output but we don't use it much. We can add this to the refactor

@max-arnold

This comment has been minimized.

max-arnold commented Jul 10, 2018

My current workaround:

pipenv lock --requirements 2> >(grep -v "Courtesy Notice" >&2) > requirements.txt

@uranusjr

This comment has been minimized.

Member

uranusjr commented Jul 10, 2018

@max-arnold You found a bug! lock -r should output to stdout (it does when you’re not in a virtualenv), but for some reason outputs to stderr when you are inside. You shouldn’t need more than pipenv lock --requirements > requirements.txt. We will fix that. Sorry for the annoyance.


Edit: After some testing, you should be able to run pipenv lock --requirements 2>/dev/null on Linux or Mac. No need for fancy grep-ing.

@max-arnold

This comment has been minimized.

max-arnold commented Jul 13, 2018

@uranusjr Fancy grep and redirections are used to filterCourtesy Notice while preserving stderr/stdout separation and exit codes.

Haplo-Dragon added a commit to Haplo-Dragon/pipenv that referenced this issue Jul 13, 2018

Add ability to suppress nested venv courtesy notice
Added an environment variable, PIPENV_SUPPRESS_NESTED_WARNING, to be
used to suppress the courtesy notice from warn_in_virtualenv.
Changed wording of the courtesy notice to mention suppression variable.
Fixes pypa#2527.

uranusjr added a commit that referenced this issue Jul 25, 2018

Add ability to suppress nested venv courtesy notice
Added an environment variable, PIPENV_SUPPRESS_NESTED_WARNING, to be
used to suppress the courtesy notice from warn_in_virtualenv.
Changed wording of the courtesy notice to mention suppression variable.
Fixes #2527.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment