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

impossible to install from http git with authentication on windows #12602

Open
1 task done
ericLemanissier opened this issue Mar 27, 2024 · 12 comments
Open
1 task done
Labels
S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior

Comments

@ericLemanissier
Copy link

Description

On windows, trying to do a pip install on a git repository (no https) with authentication does not work

Expected behavior

No response

pip version

24.0

Python version

3.12.2

OS

Windows

How to Reproduce

pip install git+http://gitea.manatecserver/el/administration.git -vvv
Using argument --keyring-provider auto leads to the same output

Output

Using pip 24.0 from C:\Users\Eric Lemanissier\env\Lib\site-packages\pip (python 3.12)
Non-user install because user site-packages disabled
Created temporary directory: C:\Users\Eric Lemanissier\AppData\Local\Temp\pip-build-tracker-q97wnc2w
Initialized build tracking at C:\Users\Eric Lemanissier\AppData\Local\Temp\pip-build-tracker-q97wnc2w
Created build tracker: C:\Users\Eric Lemanissier\AppData\Local\Temp\pip-build-tracker-q97wnc2w
Entered build tracker: C:\Users\Eric Lemanissier\AppData\Local\Temp\pip-build-tracker-q97wnc2w
Created temporary directory: C:\Users\Eric Lemanissier\AppData\Local\Temp\pip-install-i4l9fn5f
Created temporary directory: C:\Users\Eric Lemanissier\AppData\Local\Temp\pip-ephem-wheel-cache-3jsqyh4p
Collecting git+http://gitea.manatecserver/el/administration.git
  Created temporary directory: C:\Users\Eric Lemanissier\AppData\Local\Temp\pip-req-build-j6ri5gv6
  Cloning http://gitea.manatecserver/el/administration.git to c:\users\eric lemanissier\appdata\local\temp\pip-req-build-j6ri5gv6
  Running command git version
  git version 2.43.0.windows.1
  Running command git clone --filter=blob:none --verbose --progress http://gitea.manatecserver/el/administration.git 'C:\Users\Eric Lemanissier\AppData\Local\Temp\pip-req-build-j6ri5gv6'
  Cloning into 'C:\Users\Eric Lemanissier\AppData\Local\Temp\pip-req-build-j6ri5gv6'...
  bash: line 1: /dev/tty: No such device or address
  error: failed to execute prompt script (exit code 1)
  fatal: could not read Username for 'http://gitea.manatecserver': No such file or directory
  error: subprocess-exited-with-error

  × git clone --filter=blob:none --verbose --progress http://gitea.manatecserver/el/administration.git 'C:\Users\Eric Lemanissier\AppData\Local\Temp\pip-req-build-j6ri5gv6' did not run successfully.
  │ exit code: 128
  ╰─> See above for output.

  note: This error originates from a subprocess, and is likely not a problem with pip.
  full command: git clone --filter=blob:none --verbose --progress http://gitea.manatecserver/el/administration.git 'C:\Users\Eric Lemanissier\AppData\Local\Temp\pip-req-build-j6ri5gv6'
  cwd: [inherit]
error: subprocess-exited-with-error

× git clone --filter=blob:none --verbose --progress http://gitea.manatecserver/el/administration.git 'C:\Users\Eric Lemanissier\AppData\Local\Temp\pip-req-build-j6ri5gv6' did not run successfully.
│ exit code: 128
╰─> See above for output.

note: This error originates from a subprocess, and is likely not a problem with pip.
Exception information:
Traceback (most recent call last):
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\cli\base_command.py", line 180, in exc_logging_wrapper
    status = run_func(*args)
             ^^^^^^^^^^^^^^^
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\cli\req_command.py", line 245, in wrapper
    return func(self, options, args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\commands\install.py", line 377, in run
    requirement_set = resolver.resolve(
                      ^^^^^^^^^^^^^^^^^
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 76, in resolve
    collected = self.factory.collect_root_requirements(root_reqs)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 534, in collect_root_requirements
    reqs = list(
           ^^^^^
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 490, in _make_requirements_from_install_req
    cand = self._make_base_candidate_from_link(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 228, in _make_base_candidate_from_link
    self._link_candidate_cache[link] = LinkCandidate(
                                       ^^^^^^^^^^^^^^
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 290, in __init__
    super().__init__(
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 156, in __init__
    self.dist = self._prepare()
                ^^^^^^^^^^^^^^^
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 222, in _prepare
    dist = self._prepare_distribution()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py", line 301, in _prepare_distribution
    return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\operations\prepare.py", line 525, in prepare_linked_requirement
    return self._prepare_linked_requirement(req, parallel_builds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\operations\prepare.py", line 596, in _prepare_linked_requirement
    local_file = unpack_url(
                 ^^^^^^^^^^^
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\operations\prepare.py", line 157, in unpack_url
    unpack_vcs_link(link, location, verbosity=verbosity)
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\operations\prepare.py", line 80, in unpack_vcs_link
    vcs_backend.unpack(location, url=hide_url(link.url), verbosity=verbosity)
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\vcs\versioncontrol.py", line 608, in unpack
    self.obtain(location, url=url, verbosity=verbosity)
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\vcs\versioncontrol.py", line 521, in obtain
    self.fetch_new(dest, url, rev_options, verbosity=verbosity)
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\vcs\git.py", line 276, in fetch_new
    self.run_command(
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\vcs\versioncontrol.py", line 650, in run_command
    return call_subprocess(
           ^^^^^^^^^^^^^^^^
  File "C:\Users\Eric Lemanissier\env\Lib\site-packages\pip\_internal\utils\subprocess.py", line 224, in call_subprocess
    raise error
pip._internal.exceptions.InstallationSubprocessError: git clone --filter=blob:none --verbose --progress http://gitea.manatecserver/el/administration.git 'C:\Users\Eric Lemanissier\AppData\Local\Temp\pip-req-build-j6ri5gv6' exited with 128
Remote version of pip: 24.0
Local version of pip:  24.0
Was pip installed by pip? True
Removed build tracker: 'C:\\Users\\Eric Lemanissier\\AppData\\Local\\Temp\\pip-build-tracker-q97wnc2w'

Code of Conduct

@ericLemanissier ericLemanissier added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Mar 27, 2024
@ericLemanissier
Copy link
Author

FYI, on linux it works:

$ pip install git+http://gitea.manatecserver/el/administration.git -vvv
Using pip 22.0.2 from /home/eric/env/lib/python3.10/site-packages/pip (python 3.10)
Non-user install because user site-packages disabled
Created temporary directory: /tmp/pip-ephem-wheel-cache-byvcpila
Created temporary directory: /tmp/pip-req-tracker-adg44ba7
Initialized build tracking at /tmp/pip-req-tracker-adg44ba7
Created build tracker: /tmp/pip-req-tracker-adg44ba7
Entered build tracker: /tmp/pip-req-tracker-adg44ba7
Created temporary directory: /tmp/pip-install-g2nhnsa2
Collecting git+http://gitea.manatecserver/el/administration.git
  Created temporary directory: /tmp/pip-req-build-ug_2habw
  Cloning http://gitea.manatecserver/el/administration.git to /tmp/pip-req-build-ug_2habw
  Running command git version
  git version 2.34.1
  Running command git clone --filter=blob:none --verbose --progress http://gitea.manatecserver/el/administration.git /tmp/pip-req-build-ug_2habw
  Cloning into '/tmp/pip-req-build-ug_2habw'...
Username for 'http://gitea.manatecserver':

@pfmoore
Copy link
Member

pfmoore commented Mar 28, 2024

From the error:

bash: line 1: /dev/tty: No such device or address

it looks like you have some sort of Unix-specific authentication method set up in git. You need to fix your git installation to work correctly on Windows - you should be able to manually git clone http://gitea.manatecserver/el/administration.git

@ericLemanissier
Copy link
Author

ericLemanissier commented Mar 28, 2024

I use regular git for windows, and I can clone :

>git clone http://gitea.manatecserver/el/administration.git
Cloning into 'administration'...
Username for 'http://gitea.manatecserver':

also:

>git clone --filter=blob:none --verbose --progress http://gitea.manatecserver/el/administration.git "C:\Users\Eric Lemanissier\AppData\Local\Temp\pip-req-build-j6r
i5gv6"
Cloning into 'C:\Users\Eric Lemanissier\AppData\Local\Temp\pip-req-build-j6ri5gv6'...
Username for 'http://gitea.manatecserver':

@pfmoore
Copy link
Member

pfmoore commented Mar 28, 2024

But that git clone is prompting on the console. Pip is running the clone in a background process without access to the console. You need to make sure you have the relevant credentials in your keyring provider, so that git clone will run without prompting.

@ericLemanissier
Copy link
Author

as I said in #12602 (comment), the same command works on linux though, and properly asks for username and password. This is why it mostly looks like a bug on windows.
Regarding keyring, I tried to pass --keyring-provider auto --keyring-provider subprocess and --keyring-provider import but the option seems to have no effect when installing from a git repo

@pfmoore
Copy link
Member

pfmoore commented Mar 28, 2024

Understood. But there's still no evidence that it's a pip issue. Maybe someone else can help you, though.

@ericLemanissier
Copy link
Author

I guess it's because of this line
https://github.com/pypa/pip/blob/24.0/src/pip/_internal/utils/subprocess.py#L163 which was introduced in #4982 so not allowing interaction is actually a feature, not a bug. I'll see if I can somehow pre-inform git of the credentials

@pfmoore
Copy link
Member

pfmoore commented Mar 29, 2024

Sorry, that's what I was trying to tell you with

Pip is running the clone in a background process without access to the console. You need to make sure you have the relevant credentials in your keyring provider, so that git clone will run without prompting.

@ericLemanissier
Copy link
Author

Is it also a feature that pip does not use keyring for git ? (genuine question)

@pfmoore
Copy link
Member

pfmoore commented Mar 29, 2024

I'm not sure I follow. I don't think it's up to pip to "use keyring for git" - instead, it's up to git to integrate keyring if that's what you want. Are you saying that when you run git at the command line, keyring is used but when you use it via pip, keyring is not used? Git has various credential managers, I don't know if keyring is among them (also I don't know if you need it to be keyring, or if you're just assuming it should be keyring "because that's what pip uses").

Pip simply runs git non-interactively. It assumes that git will work non-interactively, it's up to you to ensure that's the case.

@ericLemanissier
Copy link
Author

I'm talking about https://pip.pypa.io/en/stable/topics/authentication/#keyring-support not being used when doing a pip install from a git repo. I expected Pip to ask keyring for the authentication, and then provide the username and/or password to git

@pfmoore
Copy link
Member

pfmoore commented Mar 29, 2024

Sorry, I don't know. I don't use pip's keyring support myself, and it was contributed by a 3rd party, so I'm not 100% clear on what the intended behaviour is in this situation. But as a practical solution to your problem, I'd suggest simply using a git credential provider that works non-interactively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants