robotframework-lsp icon indicating copy to clipboard operation
robotframework-lsp copied to clipboard

If a Library has a variable in the path, arguments are not found

Open Akselmo opened this issue 2 years ago • 1 comments

Describe the bug If a Library has a variable in the path, arguments are not found I have replicated the issue in the included zip file, but here's the gist of it:

BrokenExample.robot

*** Settings *** 
Library        ${ROOT}/libs/Example.py    ${EXAMPLE}

.vscode/settings.json

{
    "robot.variables": {"ROOT":"${workspaceFolder}", "EXAMPLE":"hello"},
    "robot.libraries.libdoc.needsArgs": ["../libs/Example.py"]
}

I've tried various different ways to use the needsArgs here: ["../libs/Example.py", "Example", "${ROOT}/libs/Example.py"]

None of them seem to fix the issue.

The library is unresolved and i get the following error

Unresolved library: ${ROOT}/libs/Example.py.
Error generating libspec:
Library 'Example' expected 1 argument, got 0.
Consider using default arguments in the ${ROOT}/libs/Example.py constructor and
calling the "Robot Framework: Clear caches and restart" action or
adding "${ROOT}/libs/Example.py" to the "robot.libraries.libdoc.needsArgs"
setting to pass the typed arguments when generating the libspec.

To Reproduce Steps to reproduce the behavior:

  1. Download the included zip
  2. Open it in VSCode
  3. Try various different parameters and the problem persists: The LS can't find the Example.py file and/or the parameter.

Expected behavior The LS would resolve the Library and it's path as normal, like when using ../libs/Example.py

Versions:

  • OS: Windows 10, Debian 11, Fedora 37 KDE
  • Robot Framework Version: 6.0.2
  • Robot Framework Language Server Version: 1.9.0
  • Client Version: VSCode 1.76

Logs logs.zip

Bug example project BrokenExample.zip

Akselmo avatar Mar 28 '23 17:03 Akselmo

From what I've gathered, it seems the ROOT variable is not resolved during the time when the docs are generated, so it doesn't match anything in the robot.libraries.libdoc.needsArgs

Akselmo avatar Apr 07 '23 17:04 Akselmo