Skip to content
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