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.

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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
neersightedcommented, Oct 11, 2022

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

0reactions
brandon-leapyearcommented, Sep 23, 2022

Note: POETRY_REPOSITORIES_XXX_URL and poetry 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 of pyproject.toml

Read more comments on GitHub >

github_iconTop Results From Across the Web

Git - Environment Variables - Git SCM
Repository Locations​​ Git uses several environment variables to determine how it interfaces with the current repository. GIT_DIR is the location of the ....
Read more >
How to set GOPRIVATE environment variable - Stack Overflow
Short Answer: go env -w GOPRIVATE=github.com/repoURL/private-repo. OR. If you want to allow all private repos from your organization
Read more >
Dockerfile reference - Docker Documentation
Environment variables are notated in the Dockerfile either with $variable_name or ${variable_name} . They are treated equivalently and the brace syntax is ...
Read more >
Configuring Environment Variables and Secrets - Render
A better solution is to store these details in environment variables and not in the app's source code. Environment variables are easy to...
Read more >
Private Repositories - Declarative GitOps CD for Kubernetes
SSH Private Key Credential¶ · Navigate to Settings/Repositories. connect repo overview · Click Connect Repo using SSH button, enter the URL and paste...
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