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

win_chocolatey fails after update to v2.4.0 #168

Open
6 tasks done
Outek opened this issue Nov 20, 2024 · 6 comments
Open
6 tasks done

win_chocolatey fails after update to v2.4.0 #168

Outek opened this issue Nov 20, 2024 · 6 comments
Labels
Improvement Issues that enhances existing functionality, or adds new features

Comments

@Outek
Copy link

Outek commented Nov 20, 2024

Checklist

  • I confirm there are no unresolved issues reported on the Chocolatey Status page.
  • I have verified this is the correct repository for opening this issue.
  • I have verified no other issues exist related to my problem.
  • I have verified this is not an issue for a specific package.
  • I have verified this issue is not security related.
  • I confirm I am using official, and not unofficial, or modified, Chocolatey products.

What You Are Seeing?

We have plans, to upgrade chocolatey(free version) to version the latest version v2.4.0, which was released last week.
Some playbooks now have errors with the new version, but if i downgrade to v2.2.2, everything is working fine again. If i try the command(choco upgrade/install packagename) manually, everything is working fine too.

What is Expected?

The package is already installed with the latest version and no error is expected.

How Did You Get This To Happen?

Check with Chocolatey 2.2.2, and rerun test after upgrade to 2.4.0

    - name: Install or update chocholatey package packagename
      chocolatey.chocolatey.win_chocolatey:
        name: packagename
        pinned: no
        state: latest
        source: https://artifactory/api/nuget/windows-nuget-local

System Details

  • Operating System: Windows Server 2019/2022 Win11
  • Windows PowerShell version: 5.1/7.4.x
  • Chocolatey CLI Version: 2.4.0

Installed Packages

n/a

Output Log

fatal: [servername]: FAILED! => {
    "changed": false,
    "choco_cli_version": "2.4.0",
    "command": "C:\\ProgramData\\chocolatey\\bin\\choco.exe upgrade packagename --fail-on-unfound --yes --no-progress --source https://artifactory/api/nuget/windows-nuget-local --timeout 2700",
    "invocation": {
        "module_args": {
            "allow_empty_checksums": false,
            "allow_multiple": false,
            "allow_prerelease": false,
            "architecture": "default",
            "bootstrap_script": null,
            "bootstrap_tls_version": [
                "tls12",
                "tls13"
            ],
            "checksum": null,
            "checksum64": null,
            "checksum_type": null,
            "checksum_type64": null,
            "choco_args": null,
            "force": false,
            "ignore_checksums": false,
            "ignore_dependencies": false,
            "install_args": null,
            "name": [
                "packagename"
            ],
            "override_args": false,
            "package_params": null,
            "pinned": false,
            "proxy_password": null,
            "proxy_url": null,
            "proxy_username": null,
            "remove_dependencies": false,
            "skip_scripts": false,
            "source": "https://artifactory/api/nuget/windows-nuget-local",
            "source_password": null,
            "source_username": null,
            "state": "latest",
            "timeout": 2700,
            "validate_certs": true,
            "version": null
        }
    },
    "msg": "Error updating package(s) 'packagename'",
    "rc": 2,
    "stderr": "",
    "stderr_lines": [],
    "stdout": "Chocolatey v2.4.0\r\nUpgrading the following packages:\r\npackagename\r\nBy upgrading, you accept licenses for the packages.\r\npackagename v1.1.10 is the latest version available based on your source(s).\r\n\r\nChocolatey upgraded 0/1 packages. \r\n See the log for details (C:\\ProgramData\\chocolatey\\logs\\chocolatey.log).\r\n",
    "stdout_lines": [
        "Chocolatey v2.4.0",
        "Upgrading the following packages:",
        "packagename",
        "By upgrading, you accept licenses for the packages.",
        "packagename v1.1.10 is the latest version available based on your source(s).",
        "",
        "Chocolatey upgraded 0/1 packages. ",
        " See the log for details (C:\\ProgramData\\chocolatey\\logs\\chocolatey.log)."
    ]
}

Additional Context

No response

@Outek Outek added the Bug Issues where something has happened which was not expected or intended label Nov 20, 2024
@gep13
Copy link
Member

gep13 commented Nov 20, 2024

@Outek on the machine where Chocolatey CLI is running, can you run the following command:

choco feature get --name=useEnhancedExitCodes

And let me know the result of that command?

The reason that I am asking is, as per the release notes for 2.3.0 of Chocolatey CLI, there were some changes to the enhancedExitCodes that Chocolatey CLI provides.

Starting with 2.3.0, there are new enhanced exit codes when running the choco upgrade command.

If you run choco upgrade -h you will see the following:

Image

Which I suspect might be the reason that you are seeing a difference between 2.2.2 and 2.4.0.

@Outek
Copy link
Author

Outek commented Nov 20, 2024

It's enabled in both versions.

PS C:\> choco feature get --name=useEnhancedExitCodes
Chocolatey v2.2.2
Enabled
PS C:\> choco feature get --name=useEnhancedExitCodes
Chocolatey v2.4.0
Enabled

@gep13
Copy link
Member

gep13 commented Nov 20, 2024

@Outek thank you for confirming!

In which case, I think this answers your question.

Using Chocolatey CLI 2.4.0 out of the box, when you attempt to run an upgrade command, on a package that is already at the highest available version available, you will get the following:

PS C:\Windows\system32> choco upgrade papercut
Chocolatey v2.3.0 Business
Upgrading the following packages:
papercut
By upgrading, you accept licenses for the packages.
papercut v6.0.0 is the latest version available based on your source(s).

Chocolatey upgraded 0/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
PS C:\Windows\system32> $lastexitcode
0
PS C:\Windows\system32>

NOTE: The exit code here is 0.

However, when you enable the useEnhancedExitCodes feature (since this is not enabled by default), you will get the following output:

PS C:\Windows\system32> choco feature enable --name=useEnhancedExitCodes
Chocolatey v2.3.0 Business
Enabled useEnhancedExitCodes
PS C:\Windows\system32> choco upgrade papercut
Chocolatey v2.3.0 Business
Upgrading the following packages:
papercut
By upgrading, you accept licenses for the packages.
papercut v6.0.0 is the latest version available based on your source(s).

Chocolatey upgraded 0/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
PS C:\Windows\system32> $lastexitcode
2
PS C:\Windows\system32>

NOTE: The exit code is now 2.

I am guessing here that Ansible is then interpreting this non-zero exit code as a failure.

I am not an Ansible expert, but I would guess that there is a way to handle this specific exit code when running this command. Or, you could disable that Chocolatey CLI feature.

@pauby pauby added the 0 - Waiting on User Insufficient information for issue or PR, issue may be closed if no response from user label Nov 20, 2024
@gep13
Copy link
Member

gep13 commented Nov 21, 2024

Based on some feedback from @jborean93 here:

ansible-collections/ansible.windows#696 (comment)

It looks like there might be some additional work to be done here to correctly handle this situation.

@Outek for now, my suggestion would be that if you are not actively using the useEnhancedExitCodes feature, that you disable it.

@gep13 gep13 added Improvement Issues that enhances existing functionality, or adds new features and removed Bug Issues where something has happened which was not expected or intended 0 - Waiting on User Insufficient information for issue or PR, issue may be closed if no response from user labels Nov 21, 2024
@gep13
Copy link
Member

gep13 commented Nov 21, 2024

I have marked this issue as an Improvement rather than a Bug since the module doesn't currently handle Enhanced Exit Codes, so I don't feel it would be right to call this a bug.

@Outek
Copy link
Author

Outek commented Nov 21, 2024

This is ok for me, thank you for the support. I changed the setting already in our dev environment without any issues. I don't know for sure, why i changed it in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement Issues that enhances existing functionality, or adds new features
Projects
None yet
Development

No branches or pull requests

3 participants