Keywords not recognized in Visual Studio Code

Keywords are nor recognized with the Robocorp Visual Studio Code extension.
It’s does not detect keywords and variables from .robot and .py files but libraries are fine.
I spend several hours on this subject without improvements.
For that reason I started from scratch with an example application but with the same results.

I created an example application based on the Extended Robot Framework template.
They problem is directly visible, the Example Keyword isn’t found.

The resource file keywords.robot isn’t also not found.
When the relative path of the resource file is specified (keyword/Keywords.robot) the keywords are found or when I change manually the settings.json or the workspace.code-workspace file:

I expect the PYTHONPATH items descripted in the robot.yaml will be/are used.
But it looks like this doesn’t work. For that reason an absolute path or changes in the settings files are needed. But maybe I did something wrong.

I used the Robocorp extensions Robocorp code v0.16.0 and Robot Framework Language Server v0.24.0.

This could have to do with the default python extension in VsCode and it’s A/B testing.

Have you tried running Set pythonPath based on robot.yaml -command via command-palette:

More details and a guide gif to opt-out of the A/B testing

Br, Kari

Yes, I tried that option but unfortunately without success

A bit more information. When I start with typing Example Keyword it will be found in the keywords/keywords.robot file. But after selecting it the resource references will be automatically updated to the relative path of the file. So in this case keywords/keywords.robot

I tested it with an user with administrator rights. Now I got the following error:

Using python executable: C:\Users\user\AppData\Local\robocorp\holotree\b1f3c244e_ea7bc223\python.exe
Waiting for Robocorp Code (python) language server to finish activating...
Took: 0.9s to initialize Robocorp Code Language Server.
Robocorp Code extension ready. Took: 17.8s
Setting the python executable path for vscode-python to be:
Error setting python.pythonPath configuration.
    Unable to write to Workspace Settings because python.pythonPath is not a registered configuration.
    Error: Unable to write to Workspace Settings because python.pythonPath is not a registered configuration.
        at E.toConfigurationEditingError (vscode-file://vscode-app/c:/Users/dijk/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1922:18845)
        at E.validate (vscode-file://vscode-app/c:/Users/dijk/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1922:21637)
        at E.doWriteConfiguration (vscode-file://vscode-app/c:/Users/dijk/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1922:15206)
        at Object.factory (vscode-file://vscode-app/c:/Users/dijk/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1922:15040)
        at u.consume (vscode-file://vscode-app/c:/Users/dijk/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:77:16613)
        at vscode-file://vscode-app/c:/Users/dijk/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:77:16428
        at new Promise (<anonymous>)
        at u.queue (vscode-file://vscode-app/c:/Users/dijk/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:77:16352)
        at E.writeConfiguration (vscode-file://vscode-app/c:/Users/dijk/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1922:15025)
        at E.writeConfigurationValue (vscode-file://vscode-app/c:/Users/dijk/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1922:44722)
        at vscode-file://vscode-app/c:/Users/dijk/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1922:30814
        at (<anonymous>)
        at E.updateValue (vscode-file://vscode-app/c:/Users/dijk/AppData/Local/Programs/Microsoft%20VS%20Code/resources/app/out/vs/workbench/workbench.desktop.main.js:1922:30802)
        at processTicksAndRejections (internal/process/task_queues.js:93:5)

Ok, something is off here.
Saw a familiar pattern in your problem and assumed a bit too much from past “scars” :wink:

We’ll look into this.

I do not get an error with my normal user account and the path to the python executable is added in the settings.json or workspace.code-workspace file.

But the PYTHONPATH references are not added. This is the content of the used robot.yaml file:

  Run all tasks:
    shell: python -m robot --report NONE --outputdir output --logtitle "Task log" tasks.robot
  Run Example task:
    robotTaskName: Example Task1

condaConfigFile: conda.yaml
artifactsDir: output_test
  - .gitignore
  - .
  - keywords
  - libraries
  - variables

See also my mails in zendesk about this with subject: Diagnostics: Robocorp Code

Hi, found the reason and a fix is released so if you update the extensions this should go away.

Perfect, this solve my problems. Thanks!

1 Like