VS Code Syntax Check links to wrong URL

Hello there,

the syntax check in VS Code is working fine, but when I try to click on a displayed problem in the “Problems” window, e.g.:

it wants to open the file from the wrong url and I get the following error message:
CannotReadFile

I am working on a MS Windows machine and Openhab is installed on a Raspberry Pi.
The problem is the same no matter if I open the folder \\OPENHABIANPI\openHAB-conf or if I am using a network drive.

This is what my settings.json looks like:

{
    "openhab.host": "openhabianpi",
    "openhab.useRestApi": true,
    "openhab.remoteLspPort": 5007,
    "openhab.remoteLspEnabled": true,
    "workbench.iconTheme": "openhab",
    "editor.renderWhitespace": "all",
    "editor.renderControlCharacters": true,
    "breadcrumbs.enabled": false,
    "openhab.paperPath": "paperui",
    "workbench.startupEditor": "none",
    "workbench.colorTheme": "Visual Studio Dark",
    "window.zoomLevel": 0,
}

Any ideas?

Thanks & best regards,
Christian

Hi,

This is a known problem with the remote language server.
Unfortunately no solution has been found yet.

1 Like

Okay, sad to hear, but thank you for the fast answer.

It would be great if this would be mentioned somewhere since I searched for quite a while yesterday before asking here.

Maybe this thread will help others until it might get fixed.

I think we should start with a known issues thread here and pin that to have a proper reference with workarounds where possible.

I will put it on the list for next week.

Hi,
I have the same issue and apparently it is still not solved.
Wonder why, because this is very annoying and makes reasonable working impossible. Does this affect only Windows users that access the openhab2 file system via samba, or why is there no bigger community voting for this issue?
To ask the other way round: How do all the other people do it for who it apparently works? So is there some kind of workaround?
Regards,
Stefan D.

Hmm… I found an ugly workaround.
It seems that VS code or the extension is completely ignoring the drive letter or originating path.
Whenever it tries to open a file, it does this relative to “C:”, which results in looking for a file actually in the path C:\etc\openhab2.
Well, to satisfy the tool, I created that directory and linked the samba file share into it by calling from an administrator’s cmd:

mklink /d C:\etc\openhab2 \\openhab\openHAB2-vscode\etc\openhab2

It’s quite ugly to have the openhab share in a folder called “etc”, but at least one can use the VS code extension now as intended.

Would be nice if this bug is fixed soon, though.

Regards,
Stefan D.

There aren’t that many .rules files in my case (maybe 20 or so). If I see the error, I just open the file via the tree view.

I would also like this to work, though.

thx for the hint with the mlink seems to work for now but yeah can’t be a permanent solution.
May I ask what happens when you for example select “Go to Definition” of an item in a rule file. Will it jump to the *.item file and display the item itself?

When I add the link to c:\etc\openhab2 the file opening is working, but my openhab log is being flooded with the following error messages every time I am typing in rules files:

2020-07-29 23:22:25.895 [ERROR] [se.xtext.ide.server.WorkspaceManager] - The document file:///etc/openhab2/rules/ZEN_Watering.rules has not been opened.
2020-07-29 23:22:26.069 [ERROR] [se.xtext.ide.server.WorkspaceManager] - The document file:///etc/openhab2/rules/ZEN_Watering.rules has not been opened.
2020-07-29 23:22:26.479 [ERROR] [se.xtext.ide.server.WorkspaceManager] - The document file:///etc/openhab2/rules/ZEN_Watering.rules has not been opened.
2020-07-29 23:22:26.641 [ERROR] [se.xtext.ide.server.WorkspaceManager] - The document file:///etc/openhab2/rules/ZEN_Watering.rules has not been opened.
2020-07-29 23:22:26.752 [ERROR] [se.xtext.ide.server.WorkspaceManager] - The document file:///etc/openhab2/rules/ZEN_Watering.rules has not been opened.

Therefore I deleted the symlink again. Do you also have this issue?

Edit:
Also I am having issues with the file change recognition then.

no for me its working however I do use a mapped drive and not the direct path to the server via \. maybe mount the folder to a drive letter in Windows and then try again,

Hi Andreas,
“Go To Definition” always jumps to the very same file and the very same line where I click on that menu item.
So this is really not helpful.
Do you say, that this function works different in other environments? My expectation would also be that the *.items file would be opened, if I say “Go To Definition” for an item name…
Regards,
Stefan D.

Hi SeeAge,
yes, today I noticed the same error messages in my openhab log. They seem to appear only if the rules file or any other file contains errors. If syntax is OK, then the log is quiet as it should be.
This development environment is really annoying. I wonder if there are setups that are better useable.

I noticed in other forum threads that some people install VS code on the openhab machine and VNC to there. Is that solution working better? Anyone knows?

Regards,
Stefan D.

I stopped using the symlink. I open the files through the tree view and do the debugging with the log viewer / syntax check in VS code.

are there any news abot this? is this still an open issue?

Yes. No progress.
Still an open issue.