Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LSP library search path does not match Robot Framework #266

Closed
osrjv opened this issue Mar 19, 2021 · 1 comment
Closed

LSP library search path does not match Robot Framework #266

osrjv opened this issue Mar 19, 2021 · 1 comment
Labels
bug Something isn't working robotframework-ls

Comments

@osrjv
Copy link

osrjv commented Mar 19, 2021

Describe the bug
Robot Framework searches relative library imports based on sys.path as a fallback. LSP only searches relative to the working directory. As a result, certain imports work while running robots, but fail when creating libspec for LSP.

RF implementation visible here: https://github.com/robotframework/robotframework/blob/f45747dfec1095359379ba0088cecd955a83e576/src/robot/utils/robotpath.py#L157

Originally reported on forums: https://forum.robocorp.com/t/vscode-new-create-robot-project-cant-find-python-keywords/589

To Reproduce
Steps to reproduce the behavior:

  1. Create Extended template with Robocorp Lab (or rcc), try to open tasks.robot with LSP

or

  1. Create the following structure:
libraries/Library.py
tasks.robot
  1. Add libraries to PYTHONPATH
  2. In tasks.robot write:

*** Settings ***
Library     Library.py

Expected behavior
Not sure. This functionality of RF doesn't seem to be documented anywhere and works differently than I expected. It is however a difference, so decided to document it here as an issue.

Versions:

  • Robot Framework Version: 3.2
  • Robot Framework Language Server Version: 0.9.1

Logs
See attached forum post

@osrjv osrjv added bug Something isn't working robotframework-ls labels Mar 19, 2021
@pekkaklarck
Copy link

It's true that Robot Framework tries to find imports like Library.py from directories in PYTHONPATH. The reason is that it uses the exact same code for finding libraries using a physical path, not name, that is uses to find resource files. This is kind of an accident and I would highly recommend importing libraries by name like Library if they are in PYTHONPATH. Since RF works that way, and there are no plans to remove this support, I guess LSP should support it as well. I just wouldn't consider it too high priority.

@fabioz fabioz closed this as completed in 1533c53 Apr 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working robotframework-ls
Projects
None yet
Development

No branches or pull requests

2 participants