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

RF Language Server Plugin for Pycharm: Cannot find external rule file for robocop #703

Closed
arnewohletz opened this issue Jul 11, 2022 · 2 comments
Labels
bug Something isn't working robotframework-ls

Comments

@arnewohletz
Copy link

arnewohletz commented Jul 11, 2022

Describe the bug
When using a custom robocop rule file (here: custom_robocop_rules.py) the RF Language Server Plugin somehow does not find it and the very first line of any robot file in my project (commonly contains *** Settings ***) is marked as erroneous and its tooltip shows the message::

Fatal error: Failed to
load external rules from file "custom_robocop_rules.py". Verify if the
file exists

image

Though when putting the rule file's absolute path into the .robocop file
(and reopen the project), the error is not shown anymore (of course,
using absolute paths is not an option, since the project is version
controlled and shared across the team).

To Reproduce
Steps to reproduce the behavior:

  1. Linting via robocop is activated (Languages & Frameworks >> RF (Project) >> Lint Rocopcop enabled + Lint Enabled -> True)
  2. Create a custom robocop rule file, for example custom_robocop_rules.py
  3. Add the rule file to your .robocop config file (use path relative to project root path):
    --ext-rules custom_robocop_rules.py
  4. Run robocop via command lines -> successfully applies custom rules
  5. Open any *.robot file within your project

Expected behavior
Any violations of custom rules are marked

Versions:

  • OS: macOS 11.6.6
  • Robot Framework Version: 5.0
  • Robot Framework Language Server Version: 0.48.2
  • Client Version: Pycharm 2022.1.2

Logs
I found this log message in the .intellij-rf-ls-2022-06-13-18898.log:

server-api: 2022-06-13 08:47:22 UTC pid: 18904 - ThreadPoolExecutor-0_0
- EXCEPTION - robotframework_ls.server_api.server
Error collecting Robocop errors (possibly an unsupported Robocop version
is installed).

Traceback (most recent call last):
   File "/Users/arnewohletz/Library/Application
Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/221.5787.24/PyCharm.app.plugins/robotframework-intellij/lib/robotframework_ls/server_api/server.py",
line 374, in _threaded_lint
     collect_robocop_diagnostics(
   File "/Users/arnewohletz/Library/Application
Support/JetBrains/Toolbox/apps/PyCharm-P/ch-0/221.5787.24/PyCharm.app.plugins/robotframework-intellij/lib/robotframework_ls/vendored/robocorp_ls_core/robocop_wrapper.py",
line 45, in collect_robocop_diagnostics
     robocop_runner.reload_config()
   File
"/Users/arnewohletz/.pyenv/versions/3.9.11/envs/robot_v5_refresh_tutorial/lib/python3.9/site-packages/robocop/run.py",
line 65, in reload_config
     self.load_checkers()
   File
"/Users/arnewohletz/.pyenv/versions/3.9.11/envs/robot_v5_refresh_tutorial/lib/python3.9/site-packages/robocop/run.py",
line 172, in load_checkers
     checkers.init(self)
   File
"/Users/arnewohletz/.pyenv/versions/3.9.11/envs/robot_v5_refresh_tutorial/lib/python3.9/site-packages/robocop/checkers/__init__.py",
line 142, in init
     for module in get_modules(linter.config.ext_rules):
   File
"/Users/arnewohletz/.pyenv/versions/3.9.11/envs/robot_v5_refresh_tutorial/lib/python3.9/site-packages/robocop/checkers/__init__.py",
line 157, in get_modules
     yield from modules_from_paths(ext_rules)
   File
"/Users/arnewohletz/.pyenv/versions/3.9.11/envs/robot_v5_refresh_tutorial/lib/python3.9/site-packages/robocop/utils/misc.py",
line 57, in modules_from_paths
     raise InvalidExternalCheckerError(path) from None
robocop.exceptions.InvalidExternalCheckerError: Fatal error: Failed to
load external rules from file "custom_robocop_rules.py". Verify if the
file exists
@bhirsz
Copy link
Contributor

bhirsz commented Jul 29, 2022

@horsewithnoname1985

it should be fixed by fabioz in lsp already but it was actually issue in Robocop as well - we are searching for config files automatically, and thus our working directory is often different that config file directory. Relative paths in config then would point to wrong paths. In the next release of the Robocop it should be fixed for pyproject.toml files. The issue stays for .robocop files, but it should be migitated by fix done in LSP.

@arnewohletz
Copy link
Author

Thank you, @bhirsz. For me, version 0.49 fixed the issue.

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

No branches or pull requests

2 participants