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

Git dependencies fail to clone with HTTPS->SSH insteadOf in git config #6329

Closed
3 tasks done
ghost opened this issue Sep 1, 2022 · 3 comments · Fixed by jelmer/dulwich#1031 or #6506
Closed
3 tasks done

Git dependencies fail to clone with HTTPS->SSH insteadOf in git config #6329

ghost opened this issue Sep 1, 2022 · 3 comments · Fixed by jelmer/dulwich#1031 or #6506
Labels
kind/bug Something isn't working as expected

Comments

@ghost
Copy link

ghost commented Sep 1, 2022

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

Issue

I have the following in ~/.config/git/config:

[url "git@github.com:"]
        insteadOf = https://github.com/

Poetry 1.2.0 seems to have introduced a regression where this causes git clones to fail:

❯ poetry init -n
❯ poetry add -vvv git+https://github.com/nyuszika7h/m3u8.git
Loading configuration file /home/nyuszika7h/.config/pypoetry/config.toml
Creating virtualenv test in /home/nyuszika7h/test/.venv
Using virtualenv: /home/nyuszika7h/test/.venv

  Stack trace:

  3  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/dulwich/client.py:1121 in fetch_pack
      1119│         with proto:
      1120│             try:
    → 1121│                 refs, server_capabilities = read_pkt_refs(proto.read_pkt_seq())
      1122│             except HangupException:
      1123│                 raise _remote_error_from_stderr(stderr)

  2  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/dulwich/client.py:240 in read_pkt_refs
       238│     refs = {}
       239│     # Receive refs from server
    →  240│     for pkt in pkt_seq:
       241│         (sha, ref) = pkt.rstrip(b"\n").split(None, 1)
       242│         if sha == b"ERR":

  1  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/dulwich/protocol.py:287 in read_pkt_seq
      285│             flush-pkt.
      286│         """
    → 287│         pkt = self.read_pkt_line()
      288│         while pkt:
      289│             yield pkt

  HangupException

  The remote server unexpectedly closed the connection.

  at ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/dulwich/protocol.py:232 in read_pkt_line
      228│
      229│         try:
      230│             sizestr = read(4)
      231│             if not sizestr:
    → 232│                 raise HangupException()
      233│             size = int(sizestr, 16)
      234│             if size == 0:
      235│                 if self.report_activity:
      236│                     self.report_activity(4, "read")

The following error occurred when trying to handle this error:


  Stack trace:

  20  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/cleo/application.py:329 in run
       327│
       328│             try:
     → 329│                 exit_code = self._run(io)
       330│             except Exception as e:
       331│                 if not self._catch_exceptions:

  19  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/console/application.py:185 in _run
       183│         self._load_plugins(io)
       184│
     → 185│         exit_code: int = super()._run(io)
       186│         return exit_code
       187│

  18  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/cleo/application.py:423 in _run
       421│             io.input.set_stream(stream)
       422│
     → 423│         exit_code = self._run_command(command, io)
       424│         self._running_command = None
       425│

  17  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/cleo/application.py:465 in _run_command
       463│
       464│         if error is not None:
     → 465│             raise error
       466│
       467│         return event.exit_code

  16  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/cleo/application.py:449 in _run_command
       447│
       448│             if event.command_should_run():
     → 449│                 exit_code = command.run(io)
       450│             else:
       451│                 exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED

  15  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/cleo/commands/base_command.py:119 in run
       117│         io.input.validate()
       118│
     → 119│         status_code = self.execute(io)
       120│
       121│         if status_code is None:

  14  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/cleo/commands/command.py:83 in execute
        81│
        82│         try:
     →  83│             return self.handle()
        84│         except KeyboardInterrupt:
        85│             return 1

  13  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/console/commands/add.py:154 in handle
       152│             return 0
       153│
     → 154│         requirements = self._determine_requirements(
       155│             packages,
       156│             allow_prereleases=self.option("allow-prereleases"),

  12  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/console/commands/init.py:357 in _determine_requirements
       355│
       356│         result = []
     → 357│         for requirement in self._parse_requirements(requires):
       358│             if "git" in requirement or "url" in requirement or "path" in requirement:
       359│                 result.append(requirement)

  11  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/console/commands/init.py:416 in _parse_requirements
       414│             cwd = Path.cwd()
       415│
     → 416│         return [
       417│             parse_dependency_specification(
       418│                 requirement=requirement,

  10  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/console/commands/init.py:417 in <listcomp>
       415│
       416│         return [
     → 417│             parse_dependency_specification(
       418│                 requirement=requirement,
       419│                 env=self.env if isinstance(self, EnvCommand) else None,

   9  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/dependency_specification.py:216 in parse_dependency_specification
       214│
       215│     specification = (
     → 216│         _parse_dependency_specification_url(requirement, env=env)
       217│         or _parse_dependency_specification_path(requirement, cwd=cwd)
       218│         or _parse_dependency_specification_simple(requirement)

   8  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/dependency_specification.py:68 in _parse_dependency_specification_url
        66│
        67│     if url_parsed.scheme in ["git+https", "git+ssh"]:
     →  68│         return _parse_dependency_specification_git_url(requirement, env)
        69│
        70│     if url_parsed.scheme in ["http", "https"]:

   7  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/dependency_specification.py:49 in _parse_dependency_specification_git_url
        47│
        48│     source_root = env.path.joinpath("src") if env else None
     →  49│     package = Provider.get_package_from_vcs(
        50│         "git",
        51│         url=url.url,

   6  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/puzzle/provider.py:342 in get_package_from_vcs
       340│             raise ValueError(f"Unsupported VCS dependency {vcs}")
       341│
     → 342│         return _get_package_from_git(
       343│             url=url,
       344│             branch=branch,

   5  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/puzzle/provider.py:96 in _get_package_from_git
        94│     source_root: Path | None = None,
        95│ ) -> Package:
     →  96│     source = Git.clone(
        97│         url=url,
        98│         source_root=source_root,

   4  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/vcs/git/backend.py:426 in clone
       424│         try:
       425│             if not cls.is_using_legacy_client():
     → 426│                 local = cls._clone(url=url, refspec=refspec, target=target)
       427│                 cls._clone_submodules(repo=local)
       428│                 return local

   3  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/vcs/git/backend.py:258 in _clone
       256│             local = Repo(str(target))
       257│
     → 258│         remote_refs = cls._fetch_remote_refs(url=url, local=local)
       259│
       260│         logger.debug(

   2  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/vcs/git/backend.py:201 in _fetch_remote_refs
       199│
       200│         with local:
     → 201│             result: FetchPackResult = client.fetch(
       202│                 path,
       203│                 local,

   1  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/dulwich/client.py:824 in fetch
        822│             f, commit, abort = target.object_store.add_pack()
        823│         try:
     →  824│             result = self.fetch_pack(
        825│                 path,
        826│                 determine_wants,

  HangupException

  ssh: Could not resolve hostname https: Name or service not known

  at ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/dulwich/client.py:1123 in fetch_pack
      1119│         with proto:
      1120│             try:
      1121│                 refs, server_capabilities = read_pkt_refs(proto.read_pkt_seq())
      1122│             except HangupException:
    → 1123│                 raise _remote_error_from_stderr(stderr)
      1124│             (
      1125│                 negotiated_capabilities,
      1126│                 symrefs,
      1127│                 agent,

This works fine, however:

[url "ssh://git@github.com/"]
        insteadOf = https://github.com/
@ghost ghost added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Sep 1, 2022
@dimbleby
Copy link
Contributor

dimbleby commented Sep 1, 2022

You'll want to report this at dulwich

Meanwhile - per the docs - there's an escape hatch https://python-poetry.org/docs/configuration/#experimentalsystem-git-client

@jelmer
Copy link
Contributor

jelmer commented Sep 4, 2022

This is now fixed in dulwich master FWIW.

jelmer added a commit to jelmer/dulwich that referenced this issue Sep 4, 2022
Previously, these were just applied to plain URLs.

Fixes python-poetry/poetry#6329
jelmer added a commit to jelmer/poetry that referenced this issue Sep 13, 2022
This version applies applyInsteadOf to rsync-style URLs. Fixes python-poetry#6329
jelmer added a commit to jelmer/poetry that referenced this issue Sep 14, 2022
This version applies applyInsteadOf to rsync-style URLs. Fixes python-poetry#6329
jelmer added a commit to jelmer/poetry that referenced this issue Sep 14, 2022
This version applies applyInsteadOf to rsync-style URLs. Fixes python-poetry#6329
mkniewallner pushed a commit that referenced this issue Sep 14, 2022
Bump to Dulwich 0.20.46.

This version applies applyInsteadOf to rsync-style URLs. Fixes #6329
@mkniewallner mkniewallner removed the status/triage This issue needs to be triaged label Sep 18, 2022
clrpackages pushed a commit to clearlinux-pkgs/pypi-dulwich that referenced this issue Sep 20, 2022
…rsion 0.20.46

Benjamin Parzella (1):
      Add 32 bit architecture for windows

Daniele Trifirò (2):
      status: return posix-style untracked paths instead of nt-style paths on win32
      gha: temporarily pin flake8 to 4.0.1

Jakub Kulík (1):
      Allow missing gpg package during tests

Jelmer Vernooij (30):
      New upstream version 0.18.0
      New upstream version 0.18.1
      New upstream version 0.18.2
      New upstream version 0.19.5
      Import upstream version 0.20.25
      Import upstream version 0.20.31
      Start on 0.20.46.
      Remove some deprecated functionality.
      Update NEWS
      Remove unused import.
      Split out exception for symbolic reference loops.
      Fix tests.
      Fix flake8 formatting compatibility.
      Fix style outside of package too.
      Improve pydoctor contents.
      Fix formatting.
      Add stub GitClient.archive.
      Don't mess with backslashes in GIT_SSH on Windows. Fixes #1008 (#1010)
      Formatting; clarify that this is just for basic authentication.
      Cope with closing bracket within quotes. Fixes #1014
      Add comment about ignoring errors from shutil.rmtree.
      Load configuration in dulwich.porcelain.clone.
      Drop support for running without setuptools.
      Drop use of certifi to find ca certificate path.
      Handle ConnectionResetError explicitly.
      Apply insteadOf to rsync-style location strings as well
      Update NEWS.
      Mark intermittently failing test_send_remove_branch test as known failing.
      Test is flaky, so skip rather than marking as known failure.
      Release 0.20.46.

Kian-Meng Ang (2):
      Prettify md/yaml files
      Fix typos

Matěj Cepl (1):
      Ignore errors when deleting GNUGPG home directory.

Saugat Pachhai (सौगात) (1):
      setup.py: advertise 3.11 support

Stefan Sperling (1):
      compat tests: honour PATH environment variable in run_git()

TuringTux (2):
      Document authentication with porcelain.clone
      Add a missing "a" back in

V24 (2):
      removed urllib3[secure]
      removed urllib3[secure]

skshetry (2):
      Add 3.11 support
      try bumping RalfG/python-wheels-manylinux-build to v0.5.0

springheeledjack0 (2):
      Implement commit signing
      Implement timezone offset detection (#1026)

wernha (1):
      Added flush before fsync

0.20.46	2022-09-06

 * Apply insteadOf to rsync-style location strings
   (previously it was just applied to URLs).
   (Jelmer Vernooij, python-poetry/poetry#6329)

 * Drop use of certifi, instead relying on urllib3's default
   code to find system CAs. (Jelmer Vernooij, #1025)

 * Implement timezone parsing in porcelain.
   (springheeledjack0, #1026)

 * Drop support for running without setuptools.
   (Jelmer Vernooij)

(NEWS truncated at 15 lines)
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
3 participants