Auth failure when installing from multiple private repos
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: Ubuntu 18.04
- Poetry version: 1.1.4
pyproject.toml
:
...
[[tool.poetry.source]]
name = "repo1"
url = "url1"
[[tool.poetry.source]]
name = "repo2"
url = "url2"
[tool.poetry.dependencies]
package1 = "1.0.0" # from repo1
package2 = "2.0.0" # from repo2
...
And the credentials are set like this:
poetry config http-basic.repo1 USERNAME1 PASSWORD1
poetry config http-basic.repo2 USERNAME2 PASSWORD2
Everything is locked perfectly in poetry.lock
with both repos marked as type = legacy
.
Issue
It is time for poetry install
and I expect both packages to be installed.
It turns out that only package1 will be installed and package2 will give this error:
RepositoryError
401 Client Error: Unauthorized for url: url2
at /usr/local/lib/python3.7/site-packages/poetry/repositories/legacy_repository.py:393 in _get
389β if response.status_code == 404:
390β return
391β response.raise_for_status()
392β except requests.HTTPError as e:
β 393β raise RepositoryError(e)
394β
395β if response.status_code in (401, 403):
396β self._log(
397β "Authorization error accessing {url}".format(url=url), level="warn"
If I explicitly set repository through poetry config repositories.repo2 url2
, it works the other way around.
Now package2 is installed and package1 will give the same error:
RepositoryError
401 Client Error: Unauthorized for url: url1
at /usr/local/lib/python3.7/site-packages/poetry/repositories/legacy_repository.py:393 in _get
389β if response.status_code == 404:
390β return
391β response.raise_for_status()
392β except requests.HTTPError as e:
β 393β raise RepositoryError(e)
394β
395β if response.status_code in (401, 403):
396β self._log(
397β "Authorization error accessing {url}".format(url=url), level="warn"
My first thought is that if I also do poetry config repositories.repo1 url1
, it will fix it.
No, it did not. Same error for package1:
RepositoryError
401 Client Error: Unauthorized for url: url1
at /usr/local/lib/python3.7/site-packages/poetry/repositories/legacy_repository.py:393 in _get
389β if response.status_code == 404:
390β return
391β response.raise_for_status()
392β except requests.HTTPError as e:
β 393β raise RepositoryError(e)
394β
395β if response.status_code in (401, 403):
396β self._log(
397β "Authorization error accessing {url}".format(url=url), level="warn"
Maybe disable the parallel installer will fix it now that I have both repositories in poetry configuration. I did poetry config installer.parallel false
. And my config looks like this (from poetry config --list
, the same checked with --local
):
cache-dir = "some-fir"
experimental.new-installer = true
installer.parallel = true
repositories.repo1.url = "url1"
repositories.repo2.url = "url2"
virtualenvs.create = true
virtualenvs.in-project = true
No, it gave me the same error for package1.
I also tried to clear pip and poetry cache by removing .cache/pip
and .cache/poetry
. It did not made a difference.
Finally, I reverted poetry configuration by unsetting the repositories and re-enabling parallel installer. And create a set of universal credentials for both repositories and set it like this:
poetry config http-basic.repo1 THE_USERNAME THE_PASSWORD
poetry config http-basic.repo2 THE_USERNAME THE_PASSWORD
And it worked. Both packages were installed without issue!
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:6
Alright, in my case I had a
.netrc
file on my system from an old experiment. This overwrites the credentials from the config. That order looks a bit strange, though. I would expect that the specific poetry configuration has a higher priority than a generic.netrc
file.@languitar issue happened for me as well. This should definitely be in the docs and/or re-prioritized. Very hard to notice it was happening too.