FHPythonUtils/LicenseCheck

Bug: licensecheck gives Indexerror: list index out of range when trying to run

Closed this issue · 2 comments

Bug

  • [x ] I have read the comment above and have completed each step
  • [x ] I have filled out the system info
  • [x ] I have described the bug, filled in the expected outcome and the actual
    outcome including screenshots where appropriate

System info

  • OS: Windows
  • Browser: Chrome
  • Version:

Describe the bug

When trying to run licensecheck after installing and installing poetry the module crashes after call:

(venv311) PS C:\Users\steve\PycharmProjects\Parcival> licensecheck                
An error occurred with poetry, try running 'poetry show' to see what went wrong! - (fall back to requirements)
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "C:\Users\steve\PycharmProjects\Parcival\venv311\Scripts\licensecheck.exe\__main__.py", line 7, in <module>
  File "C:\Users\steve\PycharmProjects\Parcival\venv311\Lib\site-packages\licensecheck\__init__.py", line 90, in cli
    myLice, depsWithLicenses = get_deps.getDepsWithLicenses(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\steve\PycharmProjects\Parcival\venv311\Lib\site-packages\licensecheck\get_deps.py", line 130, in getDepsWithLicenses
    myLice = license_matrix.licenseType(myLiceTxt)[0]
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

Tryin to run 'poetry show' as recommendet i get:

(venv311) PS C:\Users\steve\PycharmProjects\Parcival> poetry show

Poetry could not find a pyproject.toml file in C:\Users\steve\PycharmProjects\Parcival or its parents

falling back to requirements as hinted also prompts the same error

(venv311) PS C:\Users\steve\PycharmProjects\Parcival> licensecheck -u requirements
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "C:\Users\steve\PycharmProjects\Parcival\venv311\Scripts\licensecheck.exe\__main__.py", line 7, in <module>
  File "C:\Users\steve\PycharmProjects\Parcival\venv311\Lib\site-packages\licensecheck\__init__.py", line 90, in cli
    myLice, depsWithLicenses = get_deps.getDepsWithLicenses(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\steve\PycharmProjects\Parcival\venv311\Lib\site-packages\licensecheck\get_deps.py", line 130, in getDepsWithLicenses
    myLice = license_matrix.licenseType(myLiceTxt)[0]
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

Expected outcome

Getting the list of licenses or a more helpful ErrorMessage

Actual outcome

An IndexError crashing the module

Getting the same with the latest version (2023.1.4).
For me adding a [project] section (even an empty one) to my project's pyproject.toml provided a good workaround.

fixed in 2023.2