-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
python-poetry/poetry-core
#524Labels
area/coreRelated to the poetry-core libraryRelated to the poetry-core libraryarea/vcsRelated to support for VCS dependencies (Git and Dulwich)Related to support for VCS dependencies (Git and Dulwich)kind/bugSomething isn't working as expectedSomething isn't working as expectedstatus/confirmedIssue is reproduced and confirmedIssue is reproduced and confirmedversion/1.2.2
Description
- Poetry version: 1.2.2
- Python version: 3.8.10
- OS version and name: Ubuntu 22.04
- 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 (
-vvvoption) and have included the output below.
Issue
Poetry fails to parse the URL when adding git dependencies having escaped characters in the repository path.
The command
poetry add git+ssh://[email protected]:v3/myrepo/my%20repo/mylib#main -vvv
fails to find a pattern matching he URL (see the output below).
The problem seems to be in poetry.core.vcs.git.ParsedUrl.parse since the path regex PATH = r"[\w~.\-/\\\$]+" does not capture % symbols.
I tried to extend the pattern (PATH = r"[%\w~.\-/\\\$]+") and the command above finishes as expected.
Command output.
Loading configuration file /home/mauro/.config/pypoetry/config.toml
Loading configuration file /home/mauro/.config/pypoetry/auth.toml
Using virtualenv: /home/mauro/.cache/pypoetry/virtualenvs/ompi-3Z0XuDiv-py3.8
Project environment contains an empty path in sys_path, ignoring.
Stack trace:
14 ~/.local/share/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:
13 ~/.local/share/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│
12 ~/.local/share/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│
11 ~/.local/share/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
10 ~/.local/share/pypoetry/venv/lib/python3.8/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
9 ~/.local/share/pypoetry/venv/lib/python3.8/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:
8 ~/.local/share/pypoetry/venv/lib/python3.8/site-packages/cleo/commands/command.py:83 in execute
81│
82│ try:
→ 83│ return self.handle()
84│ except KeyboardInterrupt:
85│ return 1
7 ~/.local/share/pypoetry/venv/lib/python3.8/site-packages/poetry/console/commands/add.py:158 in handle
156│ return 0
157│
→ 158│ requirements = self._determine_requirements(
159│ packages,
160│ allow_prereleases=self.option("allow-prereleases"),
6 ~/.local/share/pypoetry/venv/lib/python3.8/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)
5 ~/.local/share/pypoetry/venv/lib/python3.8/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,
4 ~/.local/share/pypoetry/venv/lib/python3.8/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,
3 ~/.local/share/pypoetry/venv/lib/python3.8/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)
2 ~/.local/share/pypoetry/venv/lib/python3.8/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"]:
1 ~/.local/share/pypoetry/venv/lib/python3.8/site-packages/poetry/utils/dependency_specification.py:37 in _parse_dependency_specification_git_url
35│ from poetry.core.vcs.git import ParsedUrl
36│
→ 37│ parsed = ParsedUrl.parse(requirement)
38│ url = Git.normalize_url(requirement)
39│
ValueError
Invalid git url "git+ssh://[email protected]:v3/myrepo/my%20repo/mylib#main"
at ~/.local/share/pypoetry/venv/lib/python3.8/site-packages/poetry/core/vcs/git.py:132 in parse
128│ groups.get("rev"),
129│ groups.get("rev_subdirectory") or groups.get("subdirectory"),
130│ )
131│
→ 132│ raise ValueError(f'Invalid git url "{url}"')
133│
134│ @property
135│ def url(self) -> str:
136│ protocol = f"{self.protocol}://" if self.protocol else ""
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area/coreRelated to the poetry-core libraryRelated to the poetry-core libraryarea/vcsRelated to support for VCS dependencies (Git and Dulwich)Related to support for VCS dependencies (Git and Dulwich)kind/bugSomething isn't working as expectedSomething isn't working as expectedstatus/confirmedIssue is reproduced and confirmedIssue is reproduced and confirmedversion/1.2.2