Failing to update OH 2.4 to 2.5.7

Hi,
I’m trying to update OH from 2.4.0 to 2.5.7 and the PowerShell script fails on the backup phase.

My platform information:

  • Hardware: Intel Core i5 -2400 @3.1GHz
  • Architecture: x64/4.00GB
  • OS: Windows Server 2012 R2 Essential
  • Java Runtime Environment: Java 8
  • openHAB version: 2.4.0

Here is the log I got:

c:\openHAB2\runtime\bin>update.bat 2.5.7

#################################
#  openHAB 2.x.x update script  #
#################################

Checking whether a service exists
Checking the specified openHAB directory
Using C:\openHAB2\conf as conf folder
Using C:\openHAB2\userdata as userdata folder
Using C:\openHAB2\runtime as runtime folder
Using C:\openHAB2\addons as addons folder
The current version is 2.4.0
Changing location to C:\openHAB2
Creating temporary update directory C:\Users\OH_User\AppData\Local\Temp\openhab
Downloading the openHAB 2.5.7 distribution to C:\Users\OH_User\AppData\Local\Temp\openhab\openhab-2.5.7.zip
Downloaded 81539K of 81539K [100%]
Finished Download
Extracting the archive (C:\Users\OH_User\AppData\Local\Temp\openhab\openhab-2.5.7.zip) to C:\Users\OH_User\AppData\Local\Temp\openhab\update

#########################################################################################################################################
#  New update.ps1 was found - executing it instead (found in C:\Users\OH_User\AppData\Local\Temp\openhab\update\runtime\bin\update.ps1)  #
#########################################################################################################################################


#################################
#  openHAB 2.x.x update script  #
#################################

Checking whether a service exists
Checking the specified openHAB directory
Using C:\openHAB2\conf as conf folder
Using C:\openHAB2\userdata as userdata folder
Using C:\openHAB2\runtime as runtime folder
Using C:\openHAB2\addons as addons folder
The current version is 2.4.0
Changing location to C:\openHAB2
Upgrading to version 2.5.7

Making a backup of your distribution to C:\Users\OH_User\AppData\Local\Temp\openhab\backup-2.4.0
Creating backup directories in C:\Users\OH_User\AppData\Local\Temp\openhab\backup-2.4.0
Copying directory conf, userdata and runtime to C:\Users\OH_User\AppData\Local\Temp\openhab\backup-2.4.0\conf
#######################################################################################################
#  Could not backup existing distribution to C:\Users\OH_User\AppData\Local\Temp\openhab\backup-2.4.0  #
#######################################################################################################
PrintAndReturn : Could not find a part of the path 'C:\Users\OH_User\AppData\Local\Temp\openhab\backup-2.4.0\userdata\kar\openhab-addons-2.2.0\org\eclipse\smarthome\extensionservice\org.eclipse.smarthome.extensionservice.marketplace.automation\0.10.0.b1\org.eclipse.smarthome.extensionservice.marketplace.automation-0.10.0.b1.jar'.
At C:\Users\OH_User\AppData\Local\Temp\openhab\update\runtime\bin\update.ps1:644 char:14
+ ...        exit PrintAndReturn "Could not backup existing distribution to ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,PrintAndReturn

Press any key to continue . . .

c:\openHAB2\runtime\bin>

I tried to copy the missing file manually to the target directory and I got windows error message which says the path is too long. See error message:
image

I assume this is the reason for this issue.
Does anyone encountered this issue?

Thanks!
Shlomi

What version of Windows?

Not with a backup of openHAB, but I know that the maximum number of characters in a path is 256.
And you have 277 characters!

You should first determine whether you have more long paths in your openhab folder.

Then I would move these files from the folder(s) into a temporary folder right before the update.bat is executed.

After the update.bat has been executed successfully, copy the files back to the original location. If this is necessary at all.
.

P.S: There is a maximum of 260: three characters for the drive specification (e.g. C:\ ) and 256 characters for the path within the drive and an invisible string termination character.

1 Like

This is not an OpenHAB issue or solution. Try at your own risk.

1 Like

@Shlomi

@Bruce_Osborne Editing the Registry or a Group Policy does not work on “Windows Server 2012R2”.

See here.

I missed the OS version sorry.

Thank you for replying so fast.
You’re right, Registry or GP does not have such an option.

Regarding your previous reply:

I located the openhab files in C:\OpenHab2 - this is the shortest path I can use.
The OpenHab upgrade script chooses …\AppData\Local\Temp directory by default (which counts 36 characters). I tried to change this default path in the script, but it didn’t work.
Can I skip the backup process? would it work if I copied the files manually?

And thanks again, I appreciate your help!

@Shlomi

This could not work, because the latest update script will be downloaded during update process:

See this message from above:

#########################################################################################################################################
#  New update.ps1 was found - executing it instead (found in C:\Users\OH_User\AppData\Local\Temp\openhab\update\runtime\bin\update.ps1)  #
#########################################################################################################################################

I think no.

I bet the following is the only one with more than 260 characters (in destination folder):

C:\OpenHab2\userdata\kar\openhab-addons-2.2.0\org\eclipse\smarthome\extensionservice\org.eclipse.smarthome.extensionservice.marketplace.automation\0.10.0.b1\org.eclipse.smarthome.extensionservice.marketplace.automation-0.10.0.b1.jar

.

You could move this file into temp folder before running update.bat. And afterwards move it back to original folder.

I have the same problem upgrading to 3.0.2. My solution was to set the environment TEMP and TMP variables to C:\Temp