pauby / ChocoPackages

Chocolatey packages I maintain
26 stars 37 forks source link

(adobereader) Fails to install in Docker container #220

Open adam-clauss opened 1 month ago

adam-clauss commented 1 month ago

Checklist

Chocolatey Version

2.2.2

Chocolatey License

None

Package Version

Adobe Acrobat Reader DC 2024.2.20736

Current Behaviour

Chocolately fails to install the adobereader package when executed inside a container based on mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022.

Expected Behaviour

The package is successfully installed.

Steps To Reproduce

Execute the following commands to startup the base Microsoft image, add chocolately, then try to install adobereader.

  1. docker run --detach --interactive --tty --net=nat --name test_reader mcr.microsoft.com/dotnet/framework/sdk:4.8-windowsservercore-ltsc2022
  2. docker exec -i test_reader powershell Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))
  3. docker exec -i test_reader choco install adobereader -y

Environment

- Operating System (run `[System.Environment]::OSVersion.ToString()` in a PowerShell session): Microsoft Windows NT 10.0.20348.0
- PowerShell Version (run `$PSVersionTable` in a PowerShell session): 5.1.20348.2400
- Shell: powershell

Chocolatey Log

https://gist.github.com/adam-clauss/33674751dda6d1610e340dffda797f30

Edit: I did a subsequent run passing "-d" on the install command. That gave some more information: ERROR: Cannot index into a null array. at , C:\ProgramData\chocolatey\lib\adobereader\tools\chocolateyinstall.ps1: line 268 at , C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1: line 63 at , : line 1

Anything else?

We are running choco in some of our Docker images as a way to stage the availability of certain software. In this case, we are trying to install adobereader. This is required because it installs the ActiveX control needed to compile some software that embed a PDF viewer.

github-actions[bot] commented 1 month ago

Thanks for raising this issue!

The packages within this repository are maintained in my spare time. My spare time, like yours is important. Please help me not to waste it.

To help me, and to have the issue resolved more quickly, please see CONTRIBUTING for how to raise a pull request to resolve the issue yourself.

Thank you.

adam-clauss commented 1 month ago

I should add, I have cursory knowledge of chocolatey (I can install packages), but not much beyond that. Based on the logs, I see it is calling into a chocoatelyinstall.ps1. I tried installing the package with the "-n" flag (so it just left that ps1 file there and I could potentially debug it), but it looks to contain some Chocolatey-specific commands, so I can't just execute it directly.

pauby commented 1 month ago
ERROR: Cannot index into a null array.
at , C:\ProgramData\chocolatey\lib\adobereader\tools\chocolateyinstall.ps1: line 268
at , C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1: line 63
at , : line 1

I would guess the problem lies in these two lines.

Line 267 is getting the Uninstall Registry key which should exist as it's just installed the software in line 264 just above it. But on line 268 the array is instead of $null.

This works on a normal virtual machine, so I'm going to assume that it can't be installed inside a Docker container. It's not something I've tested and not something I support. If you can find a fix for it that I can make without altering the functionality to the package, I'm happy to accept a PR.

If the registry key does in fact exist, the issue may lie inside Get-UninstallRegistryKey.

adam-clauss commented 1 month ago

I can try to take a look - can you point me to a way to execute the Chocolatey-specific powershell script? If I just execute hte powershell script myself, it doesn't like the Chocolatey-specific commands, such as that Get-UninstallRegistryKey.

pauby commented 1 month ago

The PowerShell scripts live in $env:ChocolateyInstall\helpers.