Noise about outdated pip versions

I have a project whose environment I mantain in a flake. It uses python. When the environment is activated with nix develop or direnv (and use flake), I keep on getting informed about a new release of pip being available.

Apart from being distracting noise, I get the impression that the noise is interfering with direnv’s result caching.

Why is this happening each time the environment is activated? I can see why it might happen the first time it is built, but why does it continue? Why is some modification of the state of the outside world (a new version of pip appearing) being noticed by the supposedly stateless and hermetically-sealed build results?

What can be done to shut it up?

Because pip phones home to check if new versions exist, after the environment is built, at activation time.

There exists this handy CLI flag: pip - pip documentation v24.0

It probably just needs to be added to whatever script invokes pip.

I really doubt it.

It will happen every time pip runs. Pip is probably run during environment activation to do some environment activation. Depending on what you use, it probably does an editable installation or somesuch (which ultimately will need to set some environment variables).

I do recall reading somewhere in the direnv docs that it doesn’t like stuff appearing on stdout (but the details escape me, and I can’t find it quickly right now), and whenever stuff does appear when direnv switches (across a number of different projects) the switching clearly is slower … but maybe this is because of some environment activation activity (as you mention elsewhere) that’s happening in addition to what direnv is doing. But this is a third-order problem in the grand scheme of things, so I’ll just push it to the back of my mind.

Yes, whatever I’m using seems to be running setup.py develop and buildPythonApplication seems to be the black box to which I hand over control of all things Python. A glance over its documentation doesn’t give me any clues as to where or how I might inject the --disable-pip-version-check to which you linked.

Manually invoking

PIP_DISABLE_PIP_VERSION_CHECK=1 nix develop

does silence the warning.

But how can this check be disabled inside the flake/derivation itself?

Simply setting the environment variable in the devShell fixed the problem:

devShell = pkgs.mkShell {
    ...
    PIP_DISABLE_PIP_VERSION_CHECK = 1;
};

You can also set it in direnv if you want as an alternative :slight_smile:.