Skip to content

Git repository and package name mismatch #7113

@antoineeudes

Description

@antoineeudes
  • 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

Hello Poetry team!

I am trying to install a dependency from a private Gitlab repository. Let's call the repository foo and the library bar.
In my pyproject.toml, I added the following line:

bar = {git = "ssh://[email protected]/xxx/foo.git", develop = true, tag = "v0.13.1"}

After executing poetry install, I see that the library is successfully installed:

~ poetry run python
Python 3.8.2 (v3.8.2:7b3ab5921f, Feb 24 2020, 17:52:18)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import bar
>>> bar.__version__
'v0.13.1'

But, when I try to install another dependency, I get an error:

~ poetry add pandas

No git repository was found at /Users/me/Library/Caches/pypoetry/virtualenvs/xxxxxxxxx-py3.8/src/bar

It appears the git repository is not found in the virtual environment under the path src/bar. However, I can see the repo is there under the path src/foo. I guess there could be a confusion between the name of the library and the name of the git repository.

~ ls /Users/me/Library/Caches/pypoetry/virtualenvs/xxxxxxxxx-py3.8/src/
foo

Here is the complete log:

~  poetry -vvv add pandas
Loading configuration file /Users/me/Library/Preferences/pypoetry/config.toml
Using virtualenv: /Users/me/Library/Caches/pypoetry/virtualenvs/xxxxxxxxx-py3.8

  Stack trace:

  18  ~/Library/Application Support/pypoetry/venv/lib/python3.8/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:

  17  ~/Library/Application Support/pypoetry/venv/lib/python3.8/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│

  16  ~/Library/Application Support/pypoetry/venv/lib/python3.8/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│

  15  ~/Library/Application Support/pypoetry/venv/lib/python3.8/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

  14  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/cleo/application.py:446 in _run_command
       444│
       445│         try:
     → 446│             self._event_dispatcher.dispatch(event, COMMAND)
       447│
       448│             if event.command_should_run():

  13  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/cleo/events/event_dispatcher.py:23 in dispatch
        21│
        22│         if listeners:
     →  23│             self._do_dispatch(listeners, event_name, event)
        24│
        25│         return event

  12  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/cleo/events/event_dispatcher.py:84 in _do_dispatch
        82│                 break
        83│
     →  84│             listener(event, event_name, self)
        85│
        86│     def _sort_listeners(self, event_name: str) -> None:

  11  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/console/application.py:316 in configure_installer_for_event
       314│             return
       315│
     → 316│         cls.configure_installer_for_command(command, event.io)
       317│
       318│     @staticmethod

  10  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/console/application.py:323 in configure_installer_for_command
       321│
       322│         poetry = command.poetry
     → 323│         installer = Installer(
       324│             io,
       325│             command.env,

   9  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/installation/installer.py:79 in __init__
        77│         self._installer = self._get_installer()
        78│         if installed is None:
     →  79│             installed = self._get_installed()
        80│
        81│         self._installed_repository = installed

   8  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/installation/installer.py:573 in _get_installed
       571│
       572│     def _get_installed(self) -> InstalledRepository:
     → 573│         return InstalledRepository.load(self._env)
       574│

   7  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/repositories/installed_repository.py:291 in load
       289│                     continue
       290│
     → 291│                 package = cls.create_package_from_distribution(distribution, env)
       292│
       293│                 if with_dependencies:

   6  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/repositories/installed_repository.py:158 in create_package_from_distribution
       156│                 source_url,
       157│                 source_reference,
     → 158│             ) = cls.get_package_vcs_properties_from_path(
       159│                 env.path / "src" / canonicalize_name(distribution.metadata["name"])
       160│             )

   5  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/repositories/installed_repository.py:89 in get_package_vcs_properties_from_path
        87│         from poetry.vcs.git import Git
        88│
     →  89│         info = Git.info(repo=src)
        90│         return "git", info.origin, info.revision
        91│

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

   3  <string>:3 in __init__
         1│

   2  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/vcs/git/backend.py:144 in __post_init__
       142│
       143│     def __post_init__(self, repo: Repo | Path | str) -> None:
     → 144│         repo = Git.as_repo(repo=repo) if not isinstance(repo, Repo) else repo
       145│         self.origin = Git.get_remote_url(repo=repo, remote="origin")
       146│         self.revision = Git.get_revision(repo=repo)

   1  ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/poetry/vcs/git/backend.py:152 in as_repo
       150│     @staticmethod
       151│     def as_repo(repo: Path | str) -> Repo:
     → 152│         return Repo(str(repo))
       153│
       154│     @staticmethod

  NotGitRepository

  No git repository was found at /Users/me/Library/Caches/pypoetry/virtualenvs/xxxxxxxxx-py3.8/src/bar

  at ~/Library/Application Support/pypoetry/venv/lib/python3.8/site-packages/dulwich/repo.py:1126 in __init__
      1122│             elif (os.path.isdir(os.path.join(root, OBJECTDIR))
      1123│                     and os.path.isdir(os.path.join(root, REFSDIR))):
      1124│                 bare = True
      1125│             else:
    → 1126│                 raise NotGitRepository(
      1127│                     "No git repository was found at %(path)s" % dict(path=root)
      1128│                 )
      1129│
      1130│         self.bare = bare

Thank you !

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/vcsRelated to support for VCS dependencies (Git and Dulwich)kind/bugSomething isn't working as expectedstatus/needs-attentionNeeds eyeballs and discussion from regular contributorsstatus/triageThis issue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions