Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running Megalinter v6.2.0 fails with ModuleNotFoundError: No module named 'megalinter.tests' #1685

Closed
chgl opened this issue Aug 1, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@chgl
Copy link

chgl commented Aug 1, 2022

Describe the bug

Updating from 6.1.0 to 6.2.0 causes MegaLinter to fail with an exception when trying to run the semgrep linter.

I believe this was introduced via #1671, specifically https://github.com/oxsecurity/megalinter/pull/1671/files#diff-7e7ca1c29cf8191fada335419d7ecd0f342ef91b1c352e7bb76fd0de9995b4cdR9 - could it be that the modules under tests/ are not included in the container image?

Simply disabling semgrep via the following didn't seem to do the trick.

DISABLE_LINTERS:
  - REPOSITORY_SEMGREP

Complete traceback:

Traceback (most recent call last):
    File "/usr/local/lib/python3.10/runpy.py", line 196, in _run_module_as_main
      return _run_code(code, main_globals, None,
    File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
      exec(code, run_globals)
    File "/usr/local/lib/python3.10/site-packages/megalinter-0.1-py3.10.egg/megalinter/run.py", line 9, in <module>
      linter = megalinter.Megalinter({"cli": True})
    File "/usr/local/lib/python3.10/site-packages/megalinter-0.1-py3.10.egg/megalinter/MegaLinter.py", line 119, in __init__
      self.load_linters()
    File "/usr/local/lib/python3.10/site-packages/megalinter-0.1-py3.10.egg/megalinter/MegaLinter.py", line 457, in load_linters
      all_linters = linter_factory.list_all_linters(linter_init_params)
    File "/usr/local/lib/python3.10/site-packages/megalinter-0.1-py3.10.egg/megalinter/linter_factory.py", line 30, in list_all_linters
      descriptor_linters = build_descriptor_linters(
    File "/usr/local/lib/python3.10/site-packages/megalinter-0.1-py3.10.egg/megalinter/linter_factory.py", line 110, in build_descriptor_linters
      linter_module = importlib.import_module(
    File "/usr/local/lib/python3.10/importlib/__init__.py", line 126, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
    File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
    File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 883, in exec_module
    File "<frozen importlib._bootstrap>", line 2[41](https://github.com/chgl/fhir-server-exporter/runs/7602315091?check_suite_focus=true#step:4:42), in _call_with_frames_removed
    File "/usr/local/lib/python3.10/site-packages/megalinter-0.1-py3.10.egg/megalinter/linters/SemgrepLinter.py", line 9, in <module>
      from megalinter.tests.test_megalinter.helpers.utilstest import get_current_test_name
  ModuleNotFoundError: No module named 'megalinter.tests'

To Reproduce
Steps to reproduce the behavior:

  1. Update MegaLinter action from 6.1 to 6.2
  2. Run the linter
  3. fails with the above error

Expected behavior
After updating, MegaLinter should continue to work as before.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context

You can find a failing run over at https://github.com/chgl/fhir-server-exporter/runs/7602315091?check_suite_focus=true

Also thank you for this great tool, I'm a huge fan of linters and static code analysis and use MegaLinter everywhere I can ❤️

@chgl chgl added the bug Something isn't working label Aug 1, 2022
nvuillam added a commit that referenced this issue Aug 1, 2022
@nvuillam
Copy link
Member

nvuillam commented Aug 1, 2022

Thanks for catching !

This will be fixed in a 6.2.1 to come on within the next hours

@nvuillam nvuillam reopened this Aug 1, 2022
@nvuillam
Copy link
Member

nvuillam commented Aug 1, 2022

@chgl this is now fixed in 6.2.1, please can you check again and confirm it's ok now ? :)

@nvuillam nvuillam closed this as completed Aug 1, 2022
@chgl
Copy link
Author

chgl commented Aug 1, 2022

Works great now, thank you!

@nvuillam
Copy link
Member

nvuillam commented Aug 1, 2022

You're welcome, sorry for the bug ! (it was covered by test classes but for some strange reason the execution context was not the same )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants