- Poetry version: 1.3.1
- Python version: 3.11.1
- OS version and name: Debian bookworm (12)
- pyproject.toml: default, as created by
poetry new
Issue
poetry install with --directory=<relpath> results in error: relative path can't be expressed as a file URI.
Reproduce with:
poetry new newprj
# install fails with relative path
poetry --directory=newprj install
# => error: relative path can't be expressed as a file URI
# install succeeds with absolute path
poetry --directory=$PWD/newprj install
# => OK
Maybe check for relative paths and convert to absolute?
Output with -vvv
```log
$ poetry --directory=newprj -vvv install Loading configuration file /home/kai/.config/pypoetry/config.toml Trying to detect current active python executable as specified in the config. Found: /home/kai/.pyenv/versions/3.11.1/bin/python Trying to detect current active python executable as specified in the config. Found: /home/kai/.pyenv/versions/3.11.1/bin/python Creating virtualenv newprj-i0yJcZSZ-py3.11 in /home/kai/.cache/pypoetry/virtualenvs Using virtualenv: /home/kai/.cache/pypoetry/virtualenvs/newprj-i0yJcZSZ-py3.11 Installing dependencies from lock file Finding the necessary packages for the current system Installing the current project: newprj (0.1.0) - Building package newprj in editable mode - Adding newprj.pth to /home/kai/.cache/pypoetry/virtualenvs/newprj-i0yJcZSZ-py3.11/lib/python3.11/site-packages for newprj - Adding the newprj-0.1.0.dist-info directory to /home/kai/.cache/pypoetry/virtualenvs/newprj-i0yJcZSZ-py3.11/lib/python3.11/site-packages Stack trace: 10 ~/.local/pipx/venvs/poetry/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 9 ~/.local/pipx/venvs/poetry/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│ 8 ~/.local/pipx/venvs/poetry/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│
7 ~/.local/pipx/venvs/poetry/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
6 ~/.local/pipx/venvs/poetry/lib/python3.11/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 ~/.local/pipx/venvs/poetry/lib/python3.11/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:
4 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/commands/command.py:62 in execute
60│
61│ try:
→ 62│ return self.handle()
63│ except KeyboardInterrupt:
64│ return 1
3 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/console/commands/install.py:174 in handle
172│ return 0
173│
→ 174│ builder.build()
175│
176│ if overwrite:
2 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/masonry/builders/editable.py:80 in build
78│ added_files += self._add_pth()
79│ added_files += self._add_scripts()
→ 80│ self._add_dist_info(added_files)
81│
82│ path = self._path
1 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/masonry/builders/editable.py:252 in _add_dist_info
250│ {
251│ "dir_info": {"editable": True},
→ 252│ "url": self._poetry.file.path.parent.as_uri(),
253│ }
254│ )
ValueError
relative path can't be expressed as a file URI
at ~/.pyenv/versions/3.11.1/lib/python3.11/pathlib.py:566 in as_uri
562│
563│ def as_uri(self):
564│ """Return the path as a 'file' URI."""
565│ if not self.is_absolute():
→ 566│ raise ValueError("relative path can't be expressed as a file URI")
567│ return self._flavour.make_uri(self)
568│
569│ @Property
570│ def _cparts(self):
poetry new-vvvoption) and have included the output below.Issue
poetry install with
--directory=<relpath>results in error:relative path can't be expressed as a file URI.Reproduce with:
Maybe check for relative paths and convert to absolute?
Output with -vvv
```log $ poetry --directory=newprj -vvv install Loading configuration file /home/kai/.config/pypoetry/config.toml Trying to detect current active python executable as specified in the config. Found: /home/kai/.pyenv/versions/3.11.1/bin/python Trying to detect current active python executable as specified in the config. Found: /home/kai/.pyenv/versions/3.11.1/bin/python Creating virtualenv newprj-i0yJcZSZ-py3.11 in /home/kai/.cache/pypoetry/virtualenvs Using virtualenv: /home/kai/.cache/pypoetry/virtualenvs/newprj-i0yJcZSZ-py3.11 Installing dependencies from lock file Finding the necessary packages for the current system Installing the current project: newprj (0.1.0) - Building package newprj in editable mode - Adding newprj.pth to /home/kai/.cache/pypoetry/virtualenvs/newprj-i0yJcZSZ-py3.11/lib/python3.11/site-packages for newprj - Adding the newprj-0.1.0.dist-info directory to /home/kai/.cache/pypoetry/virtualenvs/newprj-i0yJcZSZ-py3.11/lib/python3.11/site-packages Stack trace: 10 ~/.local/pipx/venvs/poetry/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 9 ~/.local/pipx/venvs/poetry/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│ 8 ~/.local/pipx/venvs/poetry/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│7 ~/.local/pipx/venvs/poetry/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
6 ~/.local/pipx/venvs/poetry/lib/python3.11/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 ~/.local/pipx/venvs/poetry/lib/python3.11/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:
4 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/cleo/commands/command.py:62 in execute
60│
61│ try:
→ 62│ return self.handle()
63│ except KeyboardInterrupt:
64│ return 1
3 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/console/commands/install.py:174 in handle
172│ return 0
173│
→ 174│ builder.build()
175│
176│ if overwrite:
2 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/masonry/builders/editable.py:80 in build
78│ added_files += self._add_pth()
79│ added_files += self._add_scripts()
→ 80│ self._add_dist_info(added_files)
81│
82│ path = self._path
1 ~/.local/pipx/venvs/poetry/lib/python3.11/site-packages/poetry/masonry/builders/editable.py:252 in _add_dist_info
250│ {
251│ "dir_info": {"editable": True},
→ 252│ "url": self._poetry.file.path.parent.as_uri(),
253│ }
254│ )
ValueError
relative path can't be expressed as a file URI
at ~/.pyenv/versions/3.11.1/lib/python3.11/pathlib.py:566 in as_uri
562│
563│ def as_uri(self):
564│ """Return the path as a 'file' URI."""
565│ if not self.is_absolute():
→ 566│ raise ValueError("relative path can't be expressed as a file URI")
567│ return self._flavour.make_uri(self)
568│
569│ @Property
570│ def _cparts(self):