Skip to content

Surpress Stack Trace on SolverProblemError #4014

@minchinweb

Description

@minchinweb
  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Windows 10, build 19042; using Windows Terminal
  • Poetry version: 1.1.6
  • Link of a Gist with the contents of your pyproject.toml file:
# the rest...
[tool.poetry.dev-dependencies]
black = {version = "^25", allow-prereleases = true}

Issue

If a user tries to install a package version that doesn't exist, do we need to show them a stack trace of poetry?

At a minimum, could it be hidden behind a "verbose" flag?

My particular issue is this:

  • my library is managed by poetry
  • the local setup can be done using an invoke call: ctx.run(f"{POETRY} install") (where POETRY points to either the system or virtual environment as appropriate)
  • when it doesn't like a dependency version, it spits out three pages of error messages:
invoke setup
** Upgrade pip.
Requirement already satisfied: pip in e:\code\jinja-filters\.venv-unidecode\lib\site-packages (21.1)
** Install jinja_filters for development using poetry.
Installing dependencies from lock file
Warning: The lock file is not up to date with the latest changes in pyproject.toml. You may be getting outdated dependencies. Run update to update them.

  SolverProblemError

  Because pelican-jinja-filters depends on black (^25) which doesn't match any versions, version solving failed.

  at c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\poetry\puzzle\solver.py:241 in _solve
Traceback (most recent call last):
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\poetry\puzzle\solver.py", line 233, in _solve
    result = resolve_version(
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\poetry\mixology\__init__.py", line 7, in resolve_version
    return solver.solve()
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\poetry\mixology\version_solver.py", line 83, in solve
    self._propagate(next)
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\poetry\mixology\version_solver.py", line 123, in _propagate
    root_cause = self._resolve_conflict(incompatibility)
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\poetry\mixology\version_solver.py", line 321, in _resolve_conflict
    raise SolveFailure(incompatibility)
poetry.mixology.failure.SolveFailure: Because pelican-jinja-filters depends on black (^25) which doesn't match any versions, version solving failed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\clikit\console_application.py", line 131, in run
    status_code = command.handle(parsed_args, io)
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\clikit\api\command\command.py", line 120, in handle
    status_code = self._do_handle(args, io)
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\clikit\api\command\command.py", line 171, in _do_handle
    return getattr(handler, handler_method)(args, io, self)
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\cleo\commands\command.py", line 92, in wrap_handle
    return self.handle()
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\poetry\console\commands\install.py", line 71, in handle
    return_code = self._installer.run()
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\poetry\installation\installer.py", line 103, in run
    return self._do_install(local_repo)
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\poetry\installation\installer.py", line 305, in _do_install
    ops = solver.solve(use_latest=self._whitelist)
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\poetry\puzzle\solver.py", line 65, in solve
    packages, depths = self._solve(use_latest=use_latest)
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\poetry\puzzle\solver.py", line 241, in _solve
    raise SolverProblemError(e)
poetry.puzzle.exceptions.SolverProblemError: Because pelican-jinja-filters depends on black (^25) which doesn't match any versions, version solving failed.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\William\.local\bin\poetry.exe\__main__.py", line 7, in <module>
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\poetry\console\__init__.py", line 5, in main
    return Application().run()
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\clikit\console_application.py", line 142, in run
    trace.render(io, simple=isinstance(e, CliKitException))
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\clikit\ui\components\exception_trace.py", line 232, in render
    return self._render_exception(io, self._exception)
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\clikit\ui\components\exception_trace.py", line 269, in _render_exception
    self._render_snippet(io, current_frame)
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\clikit\ui\components\exception_trace.py", line 289, in _render_snippet
    self._render_line(io, code_line)
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\clikit\ui\components\exception_trace.py", line 402, in _render_line
    io.write_line("{}{}".format(indent * " ", line))
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\cleo\io\io_mixin.py", line 65, in write_line
    super(IOMixin, self).write_line(string, flags)
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\clikit\api\io\io.py", line 66, in write_line
    self._output.write_line(string, flags=flags)
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\clikit\api\io\output.py", line 69, in write_line
    self.write(string, flags=flags, new_line=True)
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\clikit\api\io\output.py", line 61, in write
    self._stream.write(to_str(formatted))
  File "c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\clikit\io\output_stream\stream_output_stream.py", line 24, in write
    self._stream.write(string)
  File "c:\python39\lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
UnicodeEncodeError: 'charmap' codec can't encode character '\u2502' in position 9: character maps to <undefined>

(\u2502 is the vertical bar on the stack trace.)

If I run poetry directly, I get a much shorter error:

poetry install
Installing dependencies from lock file
Warning: The lock file is not up to date with the latest changes in pyproject.toml. You may be getting outdated dependencies. Run update to update them.

  SolverProblemError

  Because pelican-jinja-filters depends on black (^25) which doesn't match any versions, version solving failed.

  at c:\users\william\.local\pipx\venvs\poetry\lib\site-packages\poetry\puzzle\solver.py:241 in _solve
      237│             packages = result.packages
      238│         except OverrideNeeded as e:
      239│             return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
      240│         except SolveFailure as e:
    → 241│             raise SolverProblemError(e)
      242│
      243│         results = dict(
      244│             depth_first_search(
      245│                 PackageNode(self._package, packages), aggregate_package_nodes

I spent the morning running in circles between poetry, clikit, cloe, invoke, and unidecode, with random dives into the standard library and Windows code pages. One of those pieces has decided that my terminal, on redirection, only supports ASCII code points, but inelegantly.

I see a few solutions:

  1. drop the invoke file, but we use it to manage much of the bootstraping of the project. We'd rather not, if at all possible.
  2. figure out what what is assuming the downgrade in terminal capabilities, and fix it. I spent all morning on this, and can't figure it out; maybe someone smarter than me can.
  3. Hide the stack trace. Surely the error message (Because pelican-jinja-filters depends on black (^25) which doesn't match any versions, version solving failed.) is enough for most end users?

I think the last is probably the easiest to implement. Thanks for your help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions