Poetry: Repository "private" does not exist | Since 1.1.0

Created on 7 Oct 2020  ยท  10Comments  ยท  Source: python-poetry/poetry

[[tool.poetry.source]]
name = "private"
url = "https://my.private.repo/simple"
secondary = true

Issue

When running a poetry install with a private repo (poetry config http-basic.private is set correctly), I get:

  Stack trace:

  7  /usr/local/lib/python3.7/site-packages/poetry/installation/executor.py:199 in _execute_operation
      197โ”‚
      198โ”‚             try:
    โ†’ 199โ”‚                 result = self._do_execute_operation(operation)
      200โ”‚             except EnvCommandError as e:
      201โ”‚                 if e.e.returncode == -2:

  6  /usr/local/lib/python3.7/site-packages/poetry/installation/executor.py:273 in _do_execute_operation
      271โ”‚             return 0
      272โ”‚
    โ†’ 273โ”‚         result = getattr(self, "_execute_{}".format(method))(operation)
      274โ”‚
      275โ”‚         if result != 0:

  5  /usr/local/lib/python3.7/site-packages/poetry/installation/executor.py:408 in _execute_install
      406โ”‚
      407โ”‚     def _execute_install(self, operation):  # type: (Install) -> None
    โ†’ 408โ”‚         return self._install(operation)
      409โ”‚
      410โ”‚     def _execute_update(self, operation):  # type: (Update) -> None

  4  /usr/local/lib/python3.7/site-packages/poetry/installation/executor.py:434 in _install
      432โ”‚             archive = self._download_link(operation, Link(package.source_url))
      433โ”‚         else:
    โ†’ 434โ”‚             archive = self._download(operation)
      435โ”‚
      436โ”‚         operation_message = self.get_operation_message(operation)

  3  /usr/local/lib/python3.7/site-packages/poetry/installation/executor.py:575 in _download
      573โ”‚
      574โ”‚     def _download(self, operation):  # type: (Operation) -> Path
    โ†’ 575โ”‚         link = self._chooser.choose_for(operation.package)
      576โ”‚
      577โ”‚         return self._download_link(operation, link)

  2  /usr/local/lib/python3.7/site-packages/poetry/installation/chooser.py:60 in choose_for
       58โ”‚         """
       59โ”‚         links = []
    โ†’  60โ”‚         for link in self._get_links(package):
       61โ”‚             if link.is_wheel and not Wheel(link.filename).is_supported_by_environment(
       62โ”‚                 self._env

  1  /usr/local/lib/python3.7/site-packages/poetry/installation/chooser.py:92 in _get_links
       90โ”‚                 repository = self._pool.repository("pypi")
       91โ”‚         else:
    โ†’  92โ”‚             repository = self._pool.repository(package.source_reference)
       93โ”‚
       94โ”‚         links = repository.find_links_for_package(package)

  ValueError

  Repository "private" does not exist.

  at /usr/local/lib/python3.7/site-packages/poetry/repositories/pool.py:53 in repository
       49โ”‚
       50โ”‚         if name in self._lookup:
       51โ”‚             return self._repositories[self._lookup[name]]
       52โ”‚
    โ†’  53โ”‚         raise ValueError('Repository "{}" does not exist.'.format(name))
       54โ”‚
       55โ”‚     def add_repository(
       56โ”‚         self, repository, default=False, secondary=False
       57โ”‚     ):  # type: (Repository, bool, bool) -> Pool

If I downgrade to 1.0.10, everything works fine. This error popped at the 1.1.0

Bug Repository Triage

All 10 comments

@RobinFrcd can you provide a sanitised output of poetry config repository please?

{'private': {'url': 'https://my.private.repo/simple/'}}

@RobinFrcd I am unable to reproduce this.

root@610e2455d140:/foobar# poetry add --source private foobar^C
root@610e2455d140:/foobar# cat pyproject.toml | tail -n 10

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"

[[tool.poetry.source]]
name = "private"
url = "https://my.private.repo/simple"
secondary = true

root@610e2455d140:/foobar# poetry config repositories
{'private': {'url': 'https://my.private.repo/simple'}}
root@610e2455d140:/foobar# poetry  config http-basic.private username password
No suitable keyring backends were found
Using a plaintext file to store and retrieve credentials
root@610e2455d140:/foobar# poetry add --source private foobar

  ConnectionError

  HTTPSConnectionPool(host='my.private.repo', port=443): Max retries exceeded with url: /simple/foobar/ (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f84fe257040>: Failed to establish a new connection: [Errno -2] Name or service not known'))

  at /usr/local/lib/python3.8/site-packages/requests/adapters.py:516 in send
      512โ”‚             if isinstance(e.reason, _SSLError):
      513โ”‚                 # This branch is for urllib3 v1.22 and later.
      514โ”‚                 raise SSLError(e, request=request)
      515โ”‚ 
    โ†’ 516โ”‚             raise ConnectionError(e, request=request)
      517โ”‚ 
      518โ”‚         except ClosedPoolError as e:
      519โ”‚             raise ConnectionError(e, request=request)
      520โ”‚ 

Well, the URL I gave as an example is not a valid one. I can't give the private repo I'm using for privacy reasons. The error I get is on the poetry install, not the add --source.

@RobinFrcd yeah; I am aware; i just want to demonstrate that the code got past the credential fetching.

Can you maybe try in a container or a clean environent? Just want to make sure this is not somehting environment specific.

Alright, I managed to make it work by tweaking the toml. I moved tool.poetry.dependencies to the top.

I had (which is working on 1.0.10 but not on 1.1.0+)

[[tool.poetry.source]]
name = "private"
url = "https://my.private.repo/simple/"
secondary = true

[tool.poetry]
name = "metrics"
version = "0"
description = ""
authors = [""]

[tool.black]
line-length = 88
target-version = ['py37']
include = '\.pyi?$'
exclude = '''
/(
    \.eggs
  | \.git
  | \.hg
  | \.mypy_cache
  | \.tox
  | \.venv
  | _build
  | buck-out
  | build
  | dist
)/
'''

[tool.coverage.run]
omit = [
    'tests/*',
    '*_pb2.py',
    '*_pb2_grpc.py'
]

[tool.poetry.dependencies]
python = "^3.7"
google-api-python-client = "==1.9.1"
grpcio = "==1.29.0"
grpcio-status = "==1.29.0"
private-logger = "==2.0.2"
protobuf = "==3.11.1"
sentry-sdk = "==0.15.1"
taskipy = ">=1.3.0"
numpy = "*"

[tool.poetry.dev-dependencies]
black = "==19.3b0"
flake8 = "==3.7.9"
mypy = "==0.770"

[tool.taskipy.tasks]
black = "black ."
mypy = "mypy . --ignore-missing-imports"
linter = "flake8 ."

And switched it to

[[tool.poetry.source]]
name = "private"
url = "https://my.private.repo/simple/"
secondary = true

[tool.poetry]
name = "metrics"
version = "0"
description = ""
authors = [""]

[tool.poetry.dependencies]
python = "^3.7"
google-api-python-client = "==1.9.1"
grpcio = "==1.29.0"
grpcio-status = "==1.29.0"
private-logger = "==2.0.2"
protobuf = "==3.11.1"
sentry-sdk = "==0.15.1"
taskipy = ">=1.3.0"
numpy = "*"

[tool.poetry.dev-dependencies]
black = "==19.3b0"
flake8 = "==3.7.9"
mypy = "==0.770"

[tool.black]
line-length = 88
target-version = ['py37']
include = '\.pyi?$'
exclude = '''
/(
    \.eggs
  | \.git
  | \.hg
  | \.mypy_cache
  | \.tox
  | \.venv
  | _build
  | buck-out
  | build
  | dist
)/
'''

[tool.coverage.run]
omit = [
    'tests/*',
    '*_pb2.py',
    '*_pb2_grpc.py'
]

[tool.taskipy.tasks]
black = "black ."
mypy = "mypy . --ignore-missing-imports"
linter = "flake8 ."

And now it works with 1.1.0+.

So I don't know if we should close the issue, I think it's still a bug.

I get a similar issue with the 1.1.2 version. link-python-common is a private repo project.

  โ€ข Installing link-python-common (1.0.0): Failed

  RuntimeError

  Unable to find installation candidates for link-python-common (1.0.0)

  at ~/.poetry/lib/poetry/installation/chooser.py:73 in choose_for
       69โ”‚             links.append(link)
       70โ”‚ 
       71โ”‚         if not links:
       72โ”‚             raise RuntimeError(
    โ†’  73โ”‚                 "Unable to find installation candidates for {}".format(package)
       74โ”‚             )
       75โ”‚ 
       76โ”‚         # Get the best link
       77โ”‚         chosen = max(links, key=lambda link: self._sort_key(package, link))

Example of toml file:

[[tool.poetry.source]]
name = "example-test-pypi"
url = "https://exmaple-url-pypi/pypi"
secondary=true

[tool.poetry]
name = "my-example-project-toml"
version = "0.1.0"
description = ""

[tool.poetry.dependencies]
python = "^3.7.7"
link-python-common = "^1.0.0"
xmljson = "^0.2.0"
returns = "^0.13.0"
typing_extensions = "3.7.4"
attrs = "19.1.0"
defusedxml = "^0.6.0"

[tool.poetry.dev-dependencies]
pytest = "^5.1"
mypy = "^0.770.0"
wemake-python-styleguide = "^0.14.0"
pre-commit = "^1.18"
requests = "^2.23.0"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

Also, I set poetry config http-basic.example-test-pypi my_example_pypy_user my_example_pypi_password

Is there anything I can do to fix this? I can make a PR if you guide me on where and what should be fixed.

@ChameleonTartu same issue as yours

Workaround pip install -U 'poetry<1.1.0'
failed with 1.1.0-1.1.4

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thmo picture thmo  ยท  3Comments

nikaro picture nikaro  ยท  3Comments

sobolevn picture sobolevn  ยท  3Comments

jbarlow83 picture jbarlow83  ยท  3Comments

etijskens picture etijskens  ยท  3Comments