Skip to content

[BUG] Executing format on save in VSCode fails with wrong error message about not installed robotidy #514

@hans-min

Description

@hans-min

Describe the bug
We are trying to migrate from robotidy==4.18.0 to robocop==6.7.2, and have uninstalled the old robotframework-tidy package.

In my VSCode Settings I set "editor.formatOnSave": true, so that everytime I save (Ctrl + S) a .robot file, everything is correctly formatted without having to run robocop format manually.
However, when I save a .robot file, it is not formatted at all (trailing whitespace is still there for example), and this warning from Robotcode error: Executing robotidy failed: No module named 'robotidy'

This warnings doesn't happen if I do Shift + Alt + F (shortcut for formatting document in VSCode)

Steps To Reproduce
Steps to reproduce the behavior:

  1. Pre-conditions: uninstall robotidy, install robocop > 6.0.0 and robotcode
    My RF library:
Image
  1. Go to VSCode Settings and set "editor.formatOnSave": true
  2. Go to a .robot file, add a trailing whitespace, Click Ctrl + S to save and format
***Settings***
Library  Collections

***Test Cases***
a simple test
    # add whitespace and do Ctrl + S to reproduce the problem, the whitespace won't be removed due to the error above.
    do something   
  1. See the warnings Executing robotidy failed: No module named 'robotidy'Image

Expected behavior
Whitespace should be removed, file formatted and no error popups from Robotcode

Logs
Copy the messages from VSCode "Output" view for RobotCode:

executeRobotCode: e:\Minh\ctsplusplus-rf\.venv\Scripts\python.exe -u -X utf8 c:\Users\mingp1\.vscode\extensions\d-biehl.robotcode-1.9.0\bundled\tool\robotcode --format json --no-color --no-pager -p TST5 -dp . discover --read-from-stdin all
executeRobotCode: exit code 0

and RobotCode Language Server for the specific folder/workspace: no output

Desktop (please complete the following information):

  • VS Code Version 1.104.2
  • RobotCode Version 1.9.0
  • OS: Windows Server 2019
  • Python Version 3.12.0
  • RobotFramework Version 6.1.1
  • Robocop Version 6.7.2
  • And a lot more unrelated packages

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions