robocorp / robotframework-lsp

Robocorp extensions for VS Code: Robocorp Code and RFW LSP
https://robocorp.com/docs/developer-tools/visual-studio-code
Apache License 2.0
206 stars 93 forks source link

Provide better error message if Python 3.6 or older is used to start the language server #574

Open axi92 opened 2 years ago

axi92 commented 2 years ago

Describe the problem I am not able to get it to work at all.

To Reproduce

  1. Connect vscode to a remote vscode.
  2. Install plugin remote
  3. config settings like bellow
  4. open .robot file and the keywords are not recognized
  5. Plugin Output log 3 files: https://gist.github.com/axi92/72b0b4d9df40da18c5012a9b75652447

Screenshots image

Versions:

Logs

settings.json

{
  "[robot]": {
    "editor.tabSize": 4,
    "editor.insertSpaces": true
  },
  "files.watcherExclude": {
    "**/.git/objects/**": true,
    "**/.git/subtree-cache/**": true,
    "**/node_modules/*/**": true,
    "**/libspecs/**": true,
    "**/Log/**": true
  },
  "terminal.integrated.fontFamily": "monospace",
  "robot.language-server.python": "/usr/bin/python3.8",
  "robot.python.executable": "/usr/bin/python2.7",
  "robot.language-server.args": ["-vv", "--log-file=/home/user/repo/system-life-cycle/looog/robotframework_ls.log"],
  "robot.completions.keywords.format": "Title Case",
  "robot.editor.4spacesTab": true,
  "robot.codeFormatter": "builtinTidy",
  "robot.libraries.libdoc.preGenerate": [
    "BuiltIn",
    "Collections",
    "DateTime",
    "Dialogs",
    "Easter",
    "OperatingSystem",
    "Process",
    "Reserved",
    "Screenshot",
    "String",
    "Telnet",
    "XML",
    "AppiumLibrary",
    "DatabaseLibrary",
    "Selenium2Library",
    "SSHLibrary",
    "JSONLibrary",
    "MQTTLibrary",
    "WebSocketClient"
  ]
}
fabioz commented 2 years ago

The issue here is that python 2.7 is not supported...

So, given that you're explicitly using "robot.python.executable": "/usr/bin/python2.7" in the config, this won't work.

p.s.: The requirements (https://github.com/robocorp/robotframework-lsp/tree/master/robotframework-ls#requirements) do say that 3.7 onwards is needed, but a better error message could probably be given.

axi92 commented 2 years ago

Ty I upgraded everything and it works better now. Any ideas on how I get those to work that the plugin recognizes them? image

fabioz commented 2 years ago

Ty I upgraded everything and it works better now. Any ideas on how I get those to work that the plugin recognizes them?

Usually this is because it wasn't possible to generate the libspec for the related library (you can see OUTPUT > Robot Framework for any tracebacks doing that).

https://github.com/robocorp/robotframework-lsp/blob/master/robotframework-ls/docs/faq.md#how-to-proceed-if-keywords-from-a-library-are-not-being-resolved has some more info on how to deal with that.

axi92 commented 2 years ago

Ok I think I know why it is not able to find them I imported them with Resource ${ROOT_DIR}/Keywords/OPCUA/OpcUA.robot The ROOT_DIR is defined in my red.xml that was my fix because RED was also having problems with it.

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<projectConfiguration>
    <configVersion>2</configVersion>
    <relativeTo>WORKSPACE</relativeTo>
    <variable name="${ROOT_DIR}" value="/home/user/repo/system-life-cycle/"/>

And this is also in my GlobalVariable.robot file:

*** Settings ***
Resource    ${ROOT_DIR}/Keywords/OPCUA/OpcUA.robot

*** Variables ***
${ROOT_DIR}    /home/user/repo/system-life-cycle

Robotframework got no issue with that. Any Idea on how I can fix this in vscode?

PS: If you like me to create a new issue for that I can do that too =)

fabioz commented 2 years ago

If you set that variable value for the language server it should work too.

See: https://github.com/robocorp/robotframework-lsp/blob/master/robotframework-ls/docs/faq.md#how-to-specify-a-variable-needed-to-resolve-some-library-or-resource-import how to do that.

fabioz commented 2 years ago

As a note, the docs aren't entirely correct. You can use the following variables:

${workspace}, ${workspaceRoot}, ${workspaceFolder} and ${env.ENV_NAME_VARIABLE} or ${env:ENV_NAME_VARIABLE} for the value of robot variables (this was added but docs still don't reflect that).

I'll update the docs to address shortly...

axi92 commented 2 years ago

Thank you @fabioz for helping me with my issues. Should I close the ticket or do you let it open as a task for the Error message improvement?

fabioz commented 2 years ago

You can leave it open (as I repurposed it to provide a better error in this case in the future...).