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

Whitespaces in path prevent startup of openHAB #1533

Open
spacemanspiff2007 opened this issue May 11, 2023 · 8 comments
Open

Whitespaces in path prevent startup of openHAB #1533

spacemanspiff2007 opened this issue May 11, 2023 · 8 comments

Comments

@spacemanspiff2007
Copy link
Contributor

spacemanspiff2007 commented May 11, 2023

To reproduce (on windows):
Download new windows snapshot of openHAB.
Extract into folder with whitespace (here 4.0 Snapshot_1)
Navigate into folder and doubleclick start.bat.
Observe a crash of openHAB crashes with the following error message:

Launching the openHAB runtime...
Fehler: Hauptklasse Snapshot_1 konnte nicht gefunden oder geladen werden
Ursache: java.lang.ClassNotFoundException: Snapshot_1

Replace whitespace through underscore (here 4.0_Snapshot_1) and observe successful start.

@lolodomo
Copy link
Contributor

I recently read the documentation about installation of openHAB for Windows and it is mentioned to not have space inside the path.
Now, if it could be fixed, why not ;)

@spacemanspiff2007
Copy link
Contributor Author

I think it's somewhere in the bash/cmd files the path is not properly quoted which leads to the issue.
For completeness here is the link to the docs but I think this info should be on the download page.
because it's very unexpected to not allow spaces.

@holgerfriedrich
Copy link
Member

@spacemanspiff2007 I could not reproduce your issue for start.bat, but for start_debug.bat.
Replacing "%DIRNAME%start.bat" debug %* by call "%DIRNAME%start.bat" debug %* solves the issue for me.
Can you confirm?

holgerfriedrich added a commit to holgerfriedrich/openhab-distro that referenced this issue May 14, 2023
Possibly fixes openhab#1533.

Signed-off-by: Holger Friedrich <[email protected]>
holgerfriedrich added a commit to holgerfriedrich/openhab-distro that referenced this issue May 14, 2023
Possibly fixes openhab#1533.

Signed-off-by: Holger Friedrich <[email protected]>
@spacemanspiff2007
Copy link
Contributor Author

Where have you put the space? For me it's in the last folder before the start.bat (e.g. c:\Progs\OpenHAB\4.0 Snapshot_1).
I'll double check if call will change anything and report back.

@holgerfriedrich
Copy link
Member

This is strange. I cannot reproduce anymore.
I tried the 3.4.4 release, 4.0M2, and current snapshot.
Typically, I extracted to directly to "c:\oh 4" or similar, but also tried to extract directly in the download folder.
Both start.bat and start_debug.bat now work for me, even without the proposed "fix" above.
I tried to start from explorer window, and from cmd.exe prompt.
Windows 11 Home, 22H2.

How did you start the batch files?

@spacemanspiff2007
Copy link
Contributor Author

I tried it with a double click in the containing folder, from a cmd shell inside the containing folder and through a python script that creates a new process which has the working dir set accordingly.

I looked at setenv.bat because it does not quote the file paths when setting them as JAVA_OPTS. However when I quote them I get another error in karaf.bat which I can't resolve:

"Snapshot_1"   -Dopenhab.conf="C:\Progs\openHAB\Installations\4.0" kann syntaktisch an dieser Stelle nicht verarbeitet werden.

So I am not sure if this is the right approach at all.

@holgerfriedrich
Copy link
Member

The really strange thing is that I cannot reproduce - even on an older win10 version - neither with Java11 nor Java17. It just works out of the box.
Which Java distribution are you using and is it installed to the default install location?

What I have read about escaping, using setlocal enabledelayedexpansion without any further modification could be an approach; or alternatively quoting the set calls like set "DIR=strange directory name" and quoting every use of "%DIR%".

I cannot help unless I manage to reproduce the problem.

@spacemanspiff2007
Copy link
Contributor Author

I am using Corretto and the JAVA_HOME is set accordingly:

openjdk version "17.0.6" 2023-01-17 LTS
OpenJDK Runtime Environment Corretto-17.0.6.10.1 (build 17.0.6+10-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.6.10.1 (build 17.0.6+10-LTS, mixed mode, sharing)

So you think this is a java issue and not a variable expansion issue?

I cannot help unless I manage to reproduce the problem.

Of course 🥲

What I have read about escaping, using setlocal enabledelayedexpansion without any further modification could be an approach;

That didn't work

quoting the set calls like set "DIR=strange directory name" and quoting every use of "%DIR%".

I tried that (see post above) but then I get a different error and I don't know the commands the fix the next issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants