Specifying private repository URL via environment variable not possible
See original GitHub issue-
I am on the latest Poetry version.
-
I have searched the issues of this repo and believe that this is not a duplicate.
-
If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option). -
OS version and name: Debian GNU/Linux 10 (buster)
-
Poetry version: 1.1.8
Issue
Specifying the URL of a private repository via an environment variable does not result in a working configuration. For instance after
export POETRY_REPOSITORIES_MYREPO=https://my-repo-url/
running poetry add some_package
results in
AttributeError
'str' object has no attribute 'get'
at ~/.poetry/lib/poetry/installation/authenticator.py:151 in _get_credentials_for_netloc_from_config
147│ )
148│ if not repository_config:
149│ continue
150│
→ 151│ url = repository_config.get("url")
152│ if not url:
153│ continue
154│
155│ parsed_url = urlparse.urlsplit(url)
In contrast, it works without issues when specifying the URL via poetry config
, such as
poetry config --local repositories.myrepo https://my-repo-url/
Meaning the repository is accessed without exceptions doing e.g. poetry add some_package
.
I have tracked down the cause to this code https://github.com/python-poetry/poetry/blob/master/src/poetry/config/config.py#L113-L126
It seems that the code that invokes Config.get()
expects a dictionary such as {url : "https://my-repo-url/"}
to be returned when Config.get()
is called with repositories.myrepo
as argument. And that is what happens in the lower portion of Config.get
. That code is reached only when the env variable is not set though.
When the env variable is set, the upper portion is used, which always returns a string ('https://my-repo-url/'
in this case), leading to the exception.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
This doesn’t reproduce for me on 1.2.x. @vergenzt and @tilsche are interested in something different – either #5958 or #1632.
Note:
POETRY_REPOSITORIES_XXX_URL
andpoetry config repositories.xxx
are only for publishing packages, not downloading (see https://github.com/python-poetry/poetry/issues/6004#issuecomment-1194822105). See https://github.com/python-poetry/poetry/issues/5958 for discussion on configuring sources outside ofpyproject.toml