Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Specifying private repository URL via environment variable not possible #4880

Closed
2 of 3 tasks
JnsLns opened this issue Dec 9, 2021 · 6 comments
Closed
2 of 3 tasks
Labels
status/needs-reproduction Issue needs a minimal reproduction to be confirmed

Comments

@JnsLns
Copy link

JnsLns commented Dec 9, 2021

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

@JnsLns JnsLns added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Dec 9, 2021
@vergenzt
Copy link

I'm interested in this! I'd like to use a private enterprise PyPI mirror (which is only accessible on a VPN) in CI, but default to using the live package index from developers local machines.

@abn
Copy link
Member

abn commented Jul 26, 2022

@JnsLns can you try a version >1.2.0b2 please? This should have been resolved with recent changes.

@tilsche
Copy link

tilsche commented Aug 12, 2022

I have a similar issue, a repository that contains "secret" information in its url. That should not be in a file, but in environment variable.

I have tried it with the current master. Unfortunately neither using POETRY_REPOSITORIES_XXX_URL nor poetry config --local repositories.xxx does the trick for me. In both cases poetry add fails with Could not find a matching version of package ....

@brandon-leapyear
Copy link

brandon-leapyear commented Sep 23, 2022

This is an old work account. Please reference @brandonchinn178 for all future communication


Note: POETRY_REPOSITORIES_XXX_URL and poetry config repositories.xxx are only for publishing packages, not downloading (see #6004 (comment)). See #5958 for discussion on configuring sources outside of pyproject.toml

@neersighted
Copy link
Member

This doesn't reproduce for me on 1.2.x. @vergenzt and @tilsche are interested in something different -- either #5958 or #1632.

@neersighted neersighted closed this as not planned Won't fix, can't repro, duplicate, stale Oct 11, 2022
@neersighted neersighted added status/needs-reproduction Issue needs a minimal reproduction to be confirmed and removed kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Oct 11, 2022
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status/needs-reproduction Issue needs a minimal reproduction to be confirmed
Projects
None yet
Development

No branches or pull requests

6 participants