poetry: Poetry gives cryptic error on add git dependency attempt

  • Poetry version: 1.6.1
  • Python version: 3.11.4
  • OS version and name: Mac OS 12.4
  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

I am trying to add git dependency, which is work absolutely fine with pip install git+https://github.com/Lightning-AI/lightning@master

But when I am trying to do poetry add git+https://github.com/Lightning-AI/lightning.git#master, poetry fails. adding lightning = {git = "https://github.com/Lightning-AI/lightning.git", branch = "master"} in pyproject.toml and invoking poetry update leads to the same result

poetry stack trace:

  Stack trace:

  19  ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/cleo/application.py:327 in run
       325│ 
       326│             try:
     → 327│                 exit_code = self._run(io)
       328│             except BrokenPipeError:
       329│                 # If we are piped to another process, it may close early and send a

  18  ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/poetry/console/application.py:190 in _run
       188│         self._load_plugins(io)
       189│ 
     → 190│         exit_code: int = super()._run(io)
       191│         return exit_code
       192│ 

  17  ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/cleo/application.py:431 in _run
       429│             io.input.interactive(interactive)
       430│ 
     → 431│         exit_code = self._run_command(command, io)
       432│         self._running_command = None
       433│ 

  16  ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/cleo/application.py:473 in _run_command
       471│ 
       472│         if error is not None:
     → 473│             raise error
       474│ 
       475│         return terminate_event.exit_code

  15  ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/cleo/application.py:454 in _run_command
       452│ 
       453│         try:
     → 454│             self._event_dispatcher.dispatch(command_event, COMMAND)
       455│ 
       456│             if command_event.command_should_run():

  14  ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/cleo/events/event_dispatcher.py:26 in dispatch
        24│ 
        25│         if listeners:
     →  26│             self._do_dispatch(listeners, event_name, event)
        27│ 
        28│         return event

  13  ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/cleo/events/event_dispatcher.py:89 in _do_dispatch
        87│                 break
        88│ 
     →  89│             listener(event, event_name, self)
        90│ 
        91│     def _sort_listeners(self, event_name: str) -> None:

  12  ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/poetry/console/application.py:322 in configure_installer_for_event
       320│             return
       321│ 
     → 322│         cls.configure_installer_for_command(command, event.io)
       323│ 
       324│     @staticmethod

  11  ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/poetry/console/application.py:329 in configure_installer_for_command
       327│ 
       328│         poetry = command.poetry
     → 329│         installer = Installer(
       330│             io,
       331│             command.env,

  10  ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/poetry/installation/installer.py:74 in __init__
        72│ 
        73│         if installed is None:
     →  74│             installed = self._get_installed()
        75│ 
        76│         self._installed_repository = installed

   9  ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/poetry/installation/installer.py:443 in _get_installed
       441│ 
       442│     def _get_installed(self) -> InstalledRepository:
     → 443│         return InstalledRepository.load(self._env)
       444│ 

   8  ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/poetry/repositories/installed_repository.py:274 in load
       272│                     continue
       273│ 
     → 274│                 package = cls.create_package_from_distribution(distribution, env)
       275│ 
       276│                 if with_dependencies:

   7  ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/poetry/repositories/installed_repository.py:132 in create_package_from_distribution
       130│                                 source_url,
       131│                                 source_reference,
     → 132│                             ) = cls.get_package_vcs_properties_from_path(src)
       133│                             break
       134│ 

   6  ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/poetry/repositories/installed_repository.py:80 in get_package_vcs_properties_from_path
        78│         from poetry.vcs.git import Git
        79│ 
     →  80│         info = Git.info(repo=src)
        81│         return "git", info.origin, info.revision
        82│ 

   5  ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/poetry/vcs/git/backend.py:175 in info
       173│     @classmethod
       174│     def info(cls, repo: Repo | Path) -> GitRepoLocalInfo:
     → 175│         return GitRepoLocalInfo(repo=repo)
       176│ 
       177│     @staticmethod

   4  <string>:3 in __init__
         1│ 

   3  ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/poetry/vcs/git/backend.py:147 in __post_init__
       145│         repo = Git.as_repo(repo=repo) if not isinstance(repo, Repo) else repo
       146│         self.origin = Git.get_remote_url(repo=repo, remote="origin")
     → 147│         self.revision = Git.get_revision(repo=repo)
       148│ 
       149│ 

   2  ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/poetry/vcs/git/backend.py:171 in get_revision
       169│     def get_revision(repo: Repo) -> str:
       170│         with repo:
     → 171│             return repo.head().decode("utf-8")
       172│ 
       173│     @classmethod

   1  ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/dulwich/repo.py:585 in head
        583│     def head(self) -> bytes:
        584│         """Return the SHA1 pointed at by HEAD."""
     →  585│         return self.refs[b"HEAD"]
        586│ 
        587│     def _get_object(self, sha, cls):

  KeyError

  b'HEAD'

  at ~/Library/Application Support/pypoetry/venv/lib/python3.11/site-packages/dulwich/refs.py:326 in __getitem__
       322│         This method follows all symbolic references.
       323│         """
       324│         _, sha = self.follow(name)
       325│         if sha is None:
    →  326│             raise KeyError(name)
       327│         return sha
       328│ 
       329│     def set_if_equals(
       330│         self,

About this issue

  • Original URL
  • State: open
  • Created 10 months ago
  • Reactions: 1
  • Comments: 19 (11 by maintainers)

Most upvoted comments

the error that you are reporting is completely different from what is described by this issue, please don’t hijack it.