johanjanssen / TemurinChocolateyPackages

Apache License 2.0
3 stars 4 forks source link

How to install with FeatureJavaHome and INSTALLDIR with spaces? #12

Closed rgl closed 3 years ago

rgl commented 3 years ago

The later versions of this package no longer set the JAVA_HOME environment variable, so I've tried to use the command line described at https://chocolatey.org/packages/adoptopenjdk11jre:

choco install AdoptOpenJDK11jre --params="/ADDLOCAL=FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome /INSTALLDIR=c:\Program Files\AdoptOpenJDK\ /quiet"

But it does not work, either when executed from PowerShell or from cmd, as it errors with:

Installing AdoptOpenJDK11jre...
WARNING: The command line arguments passed to the MSI are incorrect. If you passed in additional arguments, please adjust. Otherwise followup with the package maintainer(s) to get this fixed. This is most likely an issue with the 'adoptopenjdk11jre' package and not with Chocolatey itself. Please follow up with the package maintainer(s) directly.
ERROR: Running ["C:\Windows\System32\msiexec.exe" /i "C:\Users\vagrant\AppData\Local\Temp\1\chocolatey\adoptopenjdk11jre\11.0.8.11\OpenJDK11U-jre_x64_windows_hotspot_11.0.8_10.msi" /quiet InstallDir=c:\Program Files\AdoptOpenJDK\ ADDLOCAL=FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome  ] was not successful. Exit code was '1639'. Exit code indicates the following: The command line arguments passed to the MSI are incorrect. If you passed in additional arguments, please adjust. Otherwise followup with the package maintainer(s) to get this fixed. This is most likely an issue with the 'adoptopenjdk11jre' package and not with Chocolatey itself. Please follow up with the package maintainer(s) directly..
The install of adoptopenjdk11jre was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\adoptopenjdk11jre\tools\chocolateyinstall.ps1'.
 See log for details.

It seems the C:\Program Files space is messing things up, and none of the following work:

"/INSTALLDIR=C:\Program Files\AdoptOpenJDK"
/INSTALLDIR="C:\Program Files\AdoptOpenJDK"

"/INSTALLDIR=%ProgramFiles%\AdoptOpenJDK"
/INSTALLDIR="%ProgramFiles%\AdoptOpenJDK"

They either failed or installed into C:\Program\.

How are we supposed to install this into a path with spaces?

johanjanssen commented 3 years ago

Thanks for the feedback @rgl, it seems the "/" before ADDLOCAL and INSTALLDIR need to be removed.

The following worked on my machine: choco install AdoptOpenJDK11jre --params="ADDLOCAL=FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome INSTALLDIR=c:\Program Files\AdoptOpenJDK\ /quiet"

Can you confirm that it works for you as well?

@RedBaron2 did they change something in the installer? Or was it a small bug in our description?

rgl commented 3 years ago

Does not really work, instead of installing to AdoptOpenJDKxxx it still installed to AdoptOpenJDK:

PS C:\Users\vagrant> choco install -y adoptopenjdk11jre --params "ADDLOCAL=FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome INSTALLDIR=$env:Programfiles\AdoptOpenJDKxxx /quiet"
Chocolatey v0.10.15
Installing the following packages:
adoptopenjdk11jre
By installing you accept licenses for the packages.
Progress: Downloading adoptopenjdk11jre 11.0.8.11... 100%

adoptopenjdk11jre v11.0.8.11 [Approved]
adoptopenjdk11jre package files install completed. Performing other installation steps.
WARNING: Installing only Get-OSArchitectureWidth
Downloading AdoptOpenJDK11jre 64 bit
  from 'https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.8%2B10/OpenJDK11U-jre_x64_windows_hotspot_11.0.8_10.msi'
Progress: 100% - Completed download of C:\Users\vagrant\AppData\Local\Temp\1\chocolatey\adoptopenjdk11jre\11.0.8.11\OpenJDK11U-jre_x64_windows_hotspot_11.0.8_10.msi (29.14 MB).
Download of OpenJDK11U-jre_x64_windows_hotspot_11.0.8_10.msi (29.14 MB) completed.
Hashes match.
Installing AdoptOpenJDK11jre...
AdoptOpenJDK11jre has been installed.
  adoptopenjdk11jre 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 adoptopenjdk11jre was successful.
  Software installed to 'C:\Program Files\AdoptOpenJDK\jre-11.0.8.10-hotspot\'

Chocolatey installed 1/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
johanjanssen commented 3 years ago

@RedBaron2 can you help me with this one? I've done some tests, but I also didn't manage to change the installation directory.

Seems like the INSTALLDIR isn't taken into account.

If I look at Chocolatey install then I see the following: $toolsDir = @{$true="${env:ProgramFiles}\AdoptOpenJDK";$false="${env:programfiles(x86)}\AdoptOpenJDK"}[ ((Get-OSArchitectureWidth 64) -or ($env:chocolateyForceX86 -eq $true)) ]

Looks like the installdir isn't used? Or am I missing something?

RedBaron2 commented 3 years ago

@rgl Please provide the log files.

@johanjanssen That section of code is superseded in the helper, but it should be moved to the helper script.

@rgl @johanjanssen I'm testing this out right now. I will report back my findings later. Thanks for bringing it to my attention.

RedBaron2 commented 3 years ago

@rgl @johanjanssen Turns out in my previous fix for the Install Level patch. I created this problem oops 😞 I'll have the PR up tomorrow, and a patched nupkg files for download. You just need to download the All_nupkg_files.zip file. Message @RedBaron2 or @johanjanssen for instructions on how to install with these nupkg files. The PR will be submitted later today.

It seems that one of my replace commands was being a tad too sensitive.

Thanks for bringing this to our attention.

johanjanssen commented 3 years ago

@rgl I've uploaded new versions of the packages. For instance https://chocolatey.org/packages/adoptopenjdk11jre/11.0.8.1000. They're now being verified.

Can you let me know if it now works for you? I've tried a custom path and it worked on my machine.

rgl commented 3 years ago
choco install -y adoptopenjdk11jre --params (@"
/ADDLOCAL=FeatureMain,FeatureEnvironment,FeatureJarFileRunWith,FeatureJavaHome
/INSTALLDIR=$env:Programfiles\AdoptOpenJDK11JRE
/quiet
"@ -replace "`r?`n",' ')

Now installs nicely to $env:Programfiles\AdoptOpenJDK11JRE! Thanks! :-)

There is a superfluous/misleading warning about INSTALLDIR thou:

adoptopenjdk11jre package files install completed. Performing other installation steps.
WARNING: You must use INSTALLDIR with FeatureMain.
WARNING: Using provided C:\Program Files\AdoptOpenJDK11JRE

That warning should not be displayed when we specify INSTALLDIR.

RedBaron2 commented 3 years ago

@rgl That warning is to basically reflect to the user that the package parameters InstallDir / FeatureMain are detected.

FYI: It is also a word for word quote from the AdoptOpenJDK website.

The next warning shows what will be used for InstallDir .

Thanks for the reply.

johanjanssen commented 3 years ago

I think the warnings are informative, so let's keep them.

Thanks a lot @rgl for mentioning the issue and @RedBaron2 for fixing it!