python-poetry / python-poetry/poetry

poetry install --sync fails if a previously installed local editable package has been removed without using poetry remove

Open
#9,054 4 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area/deps area/installer kind/bug status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

Description
If a local directory dependency has been installed previously in editable mode, but then the directory and the references in pyproject.toml and the lock file are removed via a version control pull, for example, `poetry install --sync` will fail with an error similar to

`Directory /Users/xxx/my_package for my-package does not seem to be a Python package`

Workarounds
The removed dependency can be removed from the venv by running

`poetry run pip uninstall my-package`

After this `poetry install --sync` will work again.
Poetry Installation Method

pipx

Operating System

MacOS 14.3.1

Poetry Version

1.8.1

Poetry Configuration
cache-dir = "/Users/xxx/Library/Caches/pypoetry"
experimental.system-git-client = false
installer.max-workers = null
installer.modern-installation = true
installer.no-binary = null
installer.parallel = true
keyring.enabled = true
solver.lazy-wheel = true
virtualenvs.create = true
virtualenvs.in-project = true
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.no-setuptools = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs"  # /Users/xxx/Library/Caches/pypoetry/virtualenvs
virtualenvs.prefer-active-python = false
virtualenvs.prompt = "{project_name}-py{python_version}"
warnings.export = true
Python Sysconfig

No response

Example pyproject.toml

No response

Poetry Runtime Logs
Loading configuration file /Users/xxx/poetry.toml
Using virtualenv: /Users/xxx/.venv
Installing dependencies from lock file

Finding the necessary packages for the current system
Path /Users/xxx/my_package for my-package does not exist

  Stack trace:

  10  ~/Library/Application Support/pipx/venvs/poetry/lib/python3.12/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

   9  ~/Library/Application Support/pipx/venvs/poetry/lib/python3.12/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│ 

   8  ~/Library/Application Support/pipx/venvs/poetry/lib/python3.12/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│ 

   7  ~/Library/Application Support/pipx/venvs/poetry/lib/python3.12/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

   6  ~/Library/Application Support/pipx/venvs/poetry/lib/python3.12/site-packages/cleo/application.py:457 in _run_command
       455│ 
       456│             if command_event.command_should_run():
     → 457│                 exit_code = command.run(io)
       458│             else:
       459│                 exit_code = ConsoleCommandEvent.RETURN_CODE_DISABLED

   5  ~/Library/Application Support/pipx/venvs/poetry/lib/python3.12/site-packages/cleo/commands/base_command.py:117 in run
       115│         io.input.validate()
       116│ 
     → 117│         return self.execute(io) or 0
       118│ 
       119│     def merge_application_definition(self, merge_args: bool = True) -> None:

   4  ~/Library/Application Support/pipx/venvs/poetry/lib/python3.12/site-packages/cleo/commands/command.py:61 in execute
        59│ 
        60│         try:
     →  61│             return self.handle()
        62│         except KeyboardInterrupt:
        63│             return 1

   3  ~/Library/Application Support/pipx/venvs/poetry/lib/python3.12/site-packages/poetry/console/commands/install.py:153 in handle
       151│         self.installer.verbose(self.io.is_verbose())
       152│ 
     → 153│         return_code = self.installer.run()
       154│ 
       155│         if return_code != 0:

   2  ~/Library/Application Support/pipx/venvs/poetry/lib/python3.12/site-packages/poetry/installation/installer.py:104 in run
       102│             self.verbose(True)
       103│ 
     → 104│         return self._do_install()
       105│ 
       106│     def dry_run(self, dry_run: bool = True) -> Installer:

   1  ~/Library/Application Support/pipx/venvs/poetry/lib/python3.12/site-packages/poetry/installation/installer.py:337 in _do_install
       335│             if dep.is_file() or dep.is_directory():
       336│                 dep = cast("PathDependency", dep)
     → 337│                 dep.validate(raise_error=not op.skipped)
       338│ 
       339│         # Execute operations

  ValueError

  Path /Users/xxx/my_package for my-package does not exist

  at ~/Library/Application Support/pipx/venvs/poetry/lib/python3.12/site-packages/poetry/core/packages/path_dependency.py:82 in validate
       78│     def validate(self, *, raise_error: bool) -> bool:
       79│         if not self._validation_error:
       80│             return True
       81│         if raise_error:
    →  82│             raise ValueError(self._validation_error)
       83│         logger.warning(self._validation_error)
       84│         return False
       85│ 
       86│     @property

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the install flow in poetry/installation/installer.py and path validation in poetry/core/packages/path_dependency.py, using the reported poetry install --sync scenario as the reproduction. Trace how a removed local editable dependency is handled, then verify that syncing no longer fails with the reported missing-path error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
build-system, cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.