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

poetry config not working for HTTP auth so unable to pull private package #2125

Closed
2 of 3 tasks
viveksair opened this issue Mar 3, 2020 · 6 comments
Closed
2 of 3 tasks
Labels
kind/bug Something isn't working as expected

Comments

@viveksair
Copy link

  • 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:10 
root@91ca4e71776b:/# uname -a
Linux 91ca4e71776b 4.9.93-linuxkit-aufs #1 SMP Wed Jun 6 16:55:56 UTC 2018 x86_64 GNU/Linux
  • Poetry version:
poetry --version
Poetry version 1.0.3
  • Link of a Gist with the contents of your pyproject.toml file:
  
[tool.poetry]
name = "foo_bar"
version = "0.1.0"
description = ""
authors = ["Your Name <[email protected]>"]

[tool.poetry.dependencies]
python = "^3.7"
private_package = "^1.0.13"


[tool.poetry.dev-dependencies]



[tool.poetry.scripts]


[[tool.poetry.source]]
name = "foo"
url = "https://foo.bar/simple"
default = true		

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

Issue

$ poetry config repositories. foo https://foo.bar/simple
$ poetry config $USER_ID $USER_PASSWORD
$ poetry add private_package

[ValueError]
Could not find a matching version of package private_package

and I tried with env as well POETRY_HTTP_BASIC_FOO_USERNAME POETRY_HTTP_BASIC_FOO_PASSWORD but not working.

but poetry add private_package working after mounting config & password at ~/.config/pypoetry/auth.toml & ~/.config/pypoetry/config.toml

problem with mounting config is throwing user and password when error occurred while poetry install and I have to add default = true to [[tool.poetry.source]] to my pyproject.toml

@viveksair viveksair added the kind/bug Something isn't working as expected label Mar 3, 2020
@viveksair viveksair changed the title poetry config not working for HTTP auth so unable to private package poetry config not working for HTTP auth so unable to pull private package Mar 3, 2020
@4F2E4A2E
Copy link

Thank you poetry for being awesome and thanks @viveksair for creating this issue.

I also can confirm this bug.

Python version: 3.6.8
Poetry Version: 1.0.5

Install state: fresh install, everything from scratch
Auth: basic-auth (via env like @viveksair did, as config command, or in the url as param https://admin@admin123:foo.bar/simple) did not made any difference. No special chars in the password were used, just: admin123
Repo: I am using nexus as a repo, poetry publish is working fine via token auth, but installing the private_package is not working in any way. There are no typos and passing the exact version of the package none or the wildcard ('*') did not help.

pyproject.toml

[[tool.poetry.source]]
name = "foo"
url = "https://foo.bar/simple"
secondary = true

poetry add

poetry add -vvv private_package
Using virtualenv: /Users/foo/.pyenv/versions/3.6.8/envs/py368_tf111
PyPI: No packages found for private_package *
anofau-test: 0 packages found for private_package *

[ValueError]
Could not find a matching version of package private_package

Traceback (most recent call last):
  File "/Users/foo/.poetry/lib/poetry/_vendor/py3.6/clikit/console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "/Users/foo/.poetry/lib/poetry/_vendor/py3.6/clikit/api/command/command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "/Users/foo/.poetry/lib/poetry/_vendor/py3.6/clikit/api/command/command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "/Users/foo/.poetry/lib/poetry/_vendor/py3.6/cleo/commands/command.py", line 92, in wrap_handle
    return self.handle()
  File "/Users/foo/.poetry/lib/poetry/console/commands/add.py", line 89, in handle
    packages, allow_prereleases=self.option('allow-prereleases')
  File "/Users/foo/.poetry/lib/poetry/console/commands/init.py", line 302, in _determine_requirements
    requirement['name'], allow_prereleases=allow_prereleases
  File "/Users/foo/.poetry/lib/poetry/console/commands/init.py", line 338, in _find_best_version_for_package
    'Could not find a matching version of package {}'.format(name)

"Could not find a matching version of package {}".format(name)

@hfjn
Copy link
Contributor

hfjn commented Jun 17, 2020

Big, big thanks for poetry! ❤️

I have the exact same problem with nexus. Funnily enough pip is able to locate the image when using the exact same user, url and password:

pip search --index https://nexus.company/repository/pip/pypi package
User for nexus.company: user
Password:
package (0.1.0)  -

Poetry just spits out that I wasn't able to locate anything.

@bneijt
Copy link

bneijt commented Aug 11, 2020

When using a source with basic auth without configuring the credentials correctly, the source is silently seen as empty.

At

if response.status_code == 404:

there is only a check for 404. Meanwhile 401 is parsed, no content is found (it's a you have to log in page) and an empty list is returned, resulting in a lock simply saying there is a solver problem and no valid version is found.

After some trial and error, I was able to get poetry to pick up the basic auth configuration and see dependencies. The main issue here is that there should be a check for 200 and if not, throw an exception.

@trallnag
Copy link

trallnag commented Aug 16, 2021

I'm having the same issue... poetry config http-basic.myrepo username password is simply ignored. When I perform the install with pip install --extra-index-url it works fine. Bummer


Nevermind, I got the naming of the variables wrong

@neersighted
Copy link
Member

There was an issue with the environment variables not being respected that is long fixed on 1.2.x -- please open a new issue if you are setting the variables correctly and run into issues.

Copy link

github-actions bot commented Mar 1, 2024

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 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

6 participants