[SOLVED] OH and VScode: Server initialization failed

Running OH 2.4.0 on a rPi3B
VSC 1.37.1 on Win10
OH Extension: 0.5.1

When I start the OH workspace, the OUTPUT window in VSC shows the following:

[Error - 20:10:31] Server initialization failed.
  Message: Internal error.
  Code: -32603 
java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: Illegal character in path at index 23: file://rpi3ohv2/OpenHAB Config/things/main.things
	at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:292)
	at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:308)

My setting.json is:

    "workbench.statusBar.feedback.visible": false,
    "window.zoomLevel": 0,
    "files.trimTrailingWhitespace": true,
    "files.trimFinalNewlines": true,
    "openhab.host": "",
    "openhab.port": 8080,
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "editor.tabSize": 2

which was auto created (At least I can’t recall having set-up anything.

However, I am not sure what the consequences are of this error.
I can edit all my config…

Do you get error checking and code completion after seeing this error? That’s the real test.

If yes, than the error was probably a momentary hickup. If not then there is definitely something wrong that needs some looking into.

Do you see any errors in openhab.log?

log:set TRACE org.eclipse.smarthome.model.lsp

changed workspace in VSC

2019-08-28 20:04:43.006 [DEBUG] [thome.model.lsp.internal.ModelServer] - Client / disconnected
2019-08-28 20:05:36.457 [DEBUG] [thome.model.lsp.internal.ModelServer] - Client / connected
2019-08-28 20:05:36.457 [DEBUG] [thome.model.lsp.internal.ModelServer] - Going to wait for a client to connect
2019-08-28 20:05:36.609 [TRACE] [el.lsp.internal.MappingUriExtensions] - Going to map path file:///etc/openhab2/
2019-08-28 20:05:36.613 [TRACE] [el.lsp.internal.MappingUriExtensions] - Mapped path file://rpi3ohv2/OpenHAB Config/ to file:///etc/openhab2/

no further errors… auto-completion works.

Probably not worthwhile figuring out…

Had a look at VScode and OH2.4 M6 but do not see a relationship…

Had another look…

index 23 is the space character in the path.

[Error - 20:47:49] Server initialization failed.
  Message: Internal error.
  Code: -32603 
java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: Illegal character in path at index 23: file://rpi3ohv2/OpenHAB Config/things/main.things

My OH VCS settings:

    "workbench.statusBar.feedback.visible": false,
    "window.zoomLevel": 0,
    "files.trimTrailingWhitespace": true,
    "files.trimFinalNewlines": true,
    "openhab.host": "",
    "openhab.port": 8080,
    "openhab.karafCommand": "ssh openhab@%openhabhost% -p 8101",
    "openhab.remoteLspEnabled": true,
    "openhab.remoteLspPort": 5007,
    "editor.suggestSelection": "first",
    "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue",
    "editor.tabSize": 2

Just in case someone has an idea…

I have no clue as to where to report this issue, otherwise I would.
Anyone else having this issue?

The error is pointing to your main.things file. Usually, when it points to a space like that it is because there is an error further up in the file.

OK… here my tmain.things, which I have looked at endlessly, and canto see anything wrong with it.

// 181224-1800 MaxG: newly created; v2 bindings need these
// Thing <binding_id>:<type_id>:<thing_id> "Label" @ "Location" [ <parameters> ]
// binding : thing-type : name (default is machine name, rpi3ohv2; can be anything, here 'work', or could be 'thismachine', etc.)
Thing systeminfo:computer:local "rPi3OHv2" @ "Shed KDL" [ interval_high=3, interval_medium=60 ]

Thing ntp:ntp:local "rPi3OHv2.ntp" @ "Shed KDL" [ hostname="au.pool.ntp.org", refreshInterval=600, refreshNtp=30 ]

// ----- refer to https://www.openhab.org/addons/bindings/network/
Thing network:pingdevice:google     [ hostname="",      retry=1, timeout=5000, refreshInterval=300000 ]
Thing network:pingdevice:rpi31      [ hostname="",  retry=1, timeout=5000, refreshInterval=120000 ]
Thing network:pingdevice:rpi32      [ hostname="",  retry=1, timeout=5000, refreshInterval=120000 ]
Thing network:pingdevice:prnbrother [ hostname="", retry=1, timeout=5000, refreshInterval=120000 ]

Thing astro:sun:home  [ geolocation="-23.7164855,153.5701568", interval=60 ]
Thing astro:moon:home [ geolocation="-23.7164855,153.5701568", interval=60 ]

// https://www.openhab.org/addons/bindings/astro/
// not clear which set#start OH would use
Thing astro:sun:minus90 [ geolocation="-23.7164855,153.5701568", interval=60 ] {
    Type start : set#start [

// Thing logreader:reader:openhablog [ refreshRate=1000, errorPatterns="ERROR+", errorBlacklistingPatterns="annoying error to ignore|Another to ignore" ]
//                                     in msec
Thing logreader:reader:openhablog [ refreshRate=10000, errorPatterns="ERROR+" ]

Unfortunately, I don’t use .things files so nothing is going to be apparent to me either. Which line is 23? Not that I’m certain that 23 is what the error means by index.

You can try to move chunks of the file to separate .things files to see if you can isolate the error down to a specific Thing and then go from there.

Position 23 is the space in the path/filename.

         1         2         3         4
Illegal character in path at index 23: 
file://rpi3ohv2/OpenHAB Config/things/main.things

… an empty file creates the same error msg.

I suppose something here cannon handle paths with spaces. If its just VSCode that complains and not openHAB itself it would seem to be a problem there. In either case I’d first try taking the space out of the path to see if that makes a difference.

I shouldn’t be the only one with this problem, running OH on Linux and VSCode on Windows 10 — one would think?!

Is there an alternative way to set-up things that use the things file?

One would think so but this is the first I’ve seen this problem reported. I don’t really have any ideas.

The issue seems to have been that when connecting from VScode on Windows to an OH instance on a remote Linux host, the Samba share has to be mapped as network drive.

1 Like

Maybe we should add some kind of information in the settings dialog for the remot LSP setting,
that informs about this limitation, until we found a better solution or solved this completely.

I will add this for the next release.

At times I have seen a VSC error complaining it cannot access a .items file with a Windows filename.
Like most do, I, too, run VSC on Win 10 but OH on openHABian/Linux.

Which files does VSC actually try to access directly on Win (other than the current open one) ?
If it works on more than the currently open file that would require to have the OH .items/.rules dir mounted on some known, specific place in the Windows filesystem hierarchy else VSC cannot know e.g. where to look for a .things file that has a definition that has a channel reference in a .items file.

VSC looks and works with the currently opened files from my knowledge.
I had the impression that the lsp implementation does some own internal lookup work, but i can’t say much about that.
We would have to ask openHAB Core maintainers, since hte lsp parts are maintained there.

We have plenty threads where a share opened on windows shows the linux paths in the language error messages and then can’t be opened.
This must come from the language server code.
On extension side, we are just starting the connection to remote language server currently.