question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItΒ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 3 years ago
  • Reactions:3
  • Comments:6

github_iconTop GitHub Comments

3reactions
languitarcommented, Apr 14, 2021

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.

0reactions
crearccommented, Jul 1, 2022

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Poetry trying to install everything from private repository
So far I have tried to: explicitly set the source for each dependency in the pyproject. toml file (e.g: mypy = {version =...
Read more >
Repositories | master | Documentation | Poetry - Python ...
Private Repository Example Installing from private package sources By default, Poetry discovers and installs packages from PyPI.
Read more >
Private Dependencies GitHub - Travis CI Docs
Authentication, Protocol, Dependency URL format, Gives access to, Notes ... So a single private key cannot access multiple GitHub repositories.
Read more >
Apps with submodules or private repo dependencies
The scope of this guide mainly covers private Bitrise apps. The Git cloning submodules and repository dependencies section briefly covers how to access...
Read more >
Private Repositories - Declarative GitOps CD for Kubernetes
Private repositories that require a username and password typically have a URL ... error: code = Unknown desc = authentication required # Setup...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found