Skip to content

Fix fatal config set error #13535

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions news/13279.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed fatal error when using `PIP_CONFIG_FILE` environment variable with `pip config set`
17 changes: 16 additions & 1 deletion src/pip/_internal/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,22 @@ def _get_parser_to_modify(self) -> tuple[str, RawConfigParser]:
assert self.load_only
parsers = self._parsers[self.load_only]
if not parsers:
# This should not happen if everything works correctly.
env_config_file = os.environ.get("PIP_CONFIG_FILE")
if env_config_file and self.load_only in (kinds.USER, kinds.GLOBAL):
parser = self._construct_parser(env_config_file)
self._parsers[kinds.ENV].append((env_config_file, parser))
logger.warning(
"PIP_CONFIG_FILE is set to '{}'. "
"Applying changes to this file instead of '{}' config. "
"Note that some commands may not reflect these changes "
"as this config file is outside pip's normal config scopes. "
"Please inspect the file manually or unset "
"PIP_CONFIG_FILE for typical behavior.".format(
env_config_file, self.load_only
)
)
return env_config_file, parser

raise ConfigurationError(
"Fatal Internal error [id=2]. Please report as a bug."
)
Expand Down
Loading