flcdrg / au-packages

David's Chocolatey Automatic Packages
MIT License
18 stars 54 forks source link

ERROR: Specified cast is not valid #37

Closed flcdrg closed 6 years ago

flcdrg commented 6 years ago

From @jaganz on August 29, 2018 9:16

Installation:

C:\WINDOWS\system32>choco install sql-server-management-studio -y
Chocolatey v0.10.11
Installing the following packages:
sql-server-management-studio
By installing you accept licenses for the packages.
Progress: Downloading sql-server-management-studio 14.0.17277.0... 100%

sql-server-management-studio v14.0.17277.0 [Approved]
sql-server-management-studio package files install completed. Performing other installation steps.
ERROR: Specified cast is not valid.
The install of sql-server-management-studio was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\sql-server-management-studio\tools\chocolateyinstall.ps1'.
 See log for details.

Chocolatey installed 0/1 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures
 - sql-server-management-studio (exited -1) - Error while running 'C:\ProgramData\chocolatey\lib\sql-server-management-studio\tools\chocolateyinstall.ps1'.
 See log for details.

Logs: attached chocolatey.log

Copied from original issue: flcdrg/chocolatey-ssms#3

flcdrg commented 6 years ago

Thanks for the info and log. I wonder if it's related to the restart detection that I added recently? I'll do some testing to see if I can reproduce the problem.

flcdrg commented 6 years ago

From @jaganz on August 29, 2018 12:28

I have found something similar in this issue: https://github.com/dtgm/chocolatey-packages/issues/167 . Hope this can help you

flcdrg commented 6 years ago

Also realised I need to update the packageSourceUrl to point to the new Git repository!

flcdrg commented 6 years ago

@jaganz if you run the PowerShell script mentioned in that related issue, what output do you get?

flcdrg commented 6 years ago

From @jaganz on August 29, 2018 12:57

WARNING: Found bad key:
Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\nbi-nb-base-
8.2.0.0.201609300101
flcdrg commented 6 years ago

From @jaganz on August 29, 2018 12:59

The workaround seems to be

As you may have noticed, this bug affects many packages on chocolatey.org and most all install packages I maintain. This will be slowly snuffed out as old packages get updated. For now, the workaround is to remove the offending application, or, if you need the offending software installed, fix the bad registry key.

i'll try and give u feedback

flcdrg commented 6 years ago

Sounds good. Looks like that key is related to Netbeans (according to Google)

flcdrg commented 6 years ago

From @jaganz on August 29, 2018 13:23

Afeter deleted the bad registry entry (attached, I think that are the parameters for netbeans uninstaller) everythings works fine. thanks!

C:\WINDOWS\system32>choco install sql-server-management-studio -y Chocolatey v0.10.11 Installing the following packages: sql-server-management-studio By installing you accept licenses for the packages. Progress: Downloading sql-server-management-studio 14.0.17277.0... 100% sql-server-management-studio v14.0.17277.0 [Approved] sql-server-management-studio package files install completed. Performing other installation steps. Downloading SQL Server Management Studio from 'https://download.microsoft.com/download/0/5/B/05B2AF8F-906F-4C57-A58E-5780F64F9D62/SSMS-Setup-ENU.exe' Progress: 100% - Completed download of C:\Users\ilari\AppData\Local\Temp\chocolatey\sql-server-management-studio\14.0.17277.0\SSMS-Setup-ENU.exe (806.28 MB). Download of SSMS-Setup-ENU.exe (806.28 MB) completed. Hashes match. Installing SQL Server Management Studio... SQL Server Management Studio has been installed. sql-server-management-studio may be able to be automatically uninstalled. Environment Vars (like PATH) have changed. Close/reopen your shell to see the changes (or in powershell/cmd.exe just type refreshenv). The install of sql-server-management-studio was successful. Software installed as 'EXE', install location is likely default.

Chocolatey installed 1/1 packages. See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Registry zipped nbi-nb-base-8.2.0.0.201609300101.reg.zip

flcdrg commented 6 years ago

No worries!

wget commented 6 years ago

@flcdrg Personally I don't think this is related to your IDE doing something weird, but rather a syntax issue with PowerShell. Even if I execute the following line manually in a PowerShell window the latter complains for the same reason:

$ssms170 = Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion | Where-Object { $_.DisplayName -eq "SQL Server Management Studio" -and ([Version]$_.DisplayVersion) -ge $version17 }
wget commented 6 years ago

And for the record wrt. "the bad registry key" I hadn't Netbeans installed on my system so I'm sure the issue doesn't come from an existing key in the registry.

I think this is due to a collection that might be casted as an individual component. Somethink like this.

Just some tracks, may be completely wring, as I haven't investigated this issue properly.

flcdrg commented 6 years ago

That line runs without error on my machine (not that that helps you much!)

But I gather NetBeans was one example where there's presumably an entry under the Uninstall key in the registry which is not what Get-ItemProperty is expecting.

I'm curious, does adding -ErrorAction have any effect?

eg.

Get-ItemProperty HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* -ErrorAction SilentlyContinue | Select-Object DisplayName, DisplayVersion | Where-Object { $_.DisplayName -eq "SQL Server Management Studio" -and ([Version]$_.DisplayVersion) -ge $version17 }
flcdrg commented 6 years ago

Closing this for now. Please reopen if you have any more info