Visual Studio Code with Robot Framework Language Server reports wrong error

Hello There!

According to the page Project Structure | ROBOT FRAMEWORK,

Good Practice: Use --pythonpath command line argument and resources/ subfolder

As you can see in the image below, I did it and the script was properly executed with the commandrobot --pythonpath . .\tests\.

However, the visual code reports the following errors:

Unresolved resource: resources/common.resourcerobotframework
Unresolved variable import: data/dummy/users.pyrobotframework

As you can also see in the image, I tried to add the following setting but the problem persis.

{
    ...
    "robot.pythonpath": [
        "./",
    ],
    ...
}

Do you have any idea to solve that visual problem?

Thank you in advance!

Jefferson

Can you open the settings dialog in vs code, search for pythonpath and check the robotcode setting for pythonpath in that dialog?
Just want to be sure that your ./ is really entered there.
You could also try adding . instead of ./

1 Like

With Robot Framework Language Server you need to add absolut paths (means full paths) to the robot.pythonpath setting. The β€˜.’ is not enough. This is a bit weird because for calling robot on the command line you don’t need this.

And by the way: the robotframework language server extension is currently no longer being actively developed.

2 Likes

Oh, I overlooked that it is about LSP (and not Robot Code).

With LSP you can avoid typing the full path by using some variables.
So you can add the Pythonpath like that to the settings:

"robot.pythonpath": [
    "${workspaceFolder}", "${workspaceFolder}/lib", "${workspaceFolder}/resources", "${workspaceFolder}/keywords"
    ]

${workspaceFolder} means here your project root folder.
It will be resolved to the absolute path

2 Likes

This message gives me all we need. Thank you!

Just a final comment. I verified that the problem was solved adding only the workspace folder as showed below

{
    ...
    "robot.pythonpath": [
        "${workspaceFolder}"
        ]
} 
1 Like