choco pack command fails on non-Windows when the nupkg already exists
TheCakeIsNaOH opened this issue · 3 comments
What You Are Seeing?
When running choco pack
on Mono on a Linux system, it will fail to pack if the .nupkg
already exists.
What is Expected?
That choco pack
will work even if the .nupkg
already exists.
How Did You Get This To Happen? (Steps to Reproduce)
- Setup
choco
on Mono on Linux. - Create or copy package source files to pack.
- Run
choco pack
twice on that package source.
Output Log
Full Log Output
Important bits
2020-07-04 09:24:24,788 30949 [DEBUG] - _ Chocolatey:ChocolateyPackCommand - Normal Run Mode _
2020-07-04 09:24:24,943 30949 [INFO ] - Attempting to build package from 'anydesk.nuspec'.
2020-07-04 09:24:25,016 30949 [DEBUG] - Sending message 'PostRunMessage' out if there are subscribers...
2020-07-04 09:24:25,018 30949 [ERROR] - This partUri is already contained in the package
2020-07-04 09:24:25,019 30949 [ERROR] - More Details: System.InvalidOperationException: This partUri is already contained in the package
at System.IO.Packaging.Package.CreatePart (System.Uri partUri, System.String contentType, System.IO.Packaging.CompressionOption compressionOption) [0x0001b] in <a0ec8c343cb4418c9a045f20ad533b4e>:0
at NuGet.PackageBuilder.WriteManifest (System.IO.Packaging.Package package, System.Int32 minimumManifestVersion) [0x00024] in <23136ac9008c43ea82679714836f769c>:0
at NuGet.PackageBuilder.Save (System.IO.Stream stream) [0x000c5] in <23136ac9008c43ea82679714836f769c>:0
at chocolatey.infrastructure.app.nuget.NugetPack.BuildPackage (NuGet.PackageBuilder builder, chocolatey.infrastructure.filesystem.IFileSystem fileSystem, System.String outputPath) [0x00044] in <273947f2641b4ad5bcc7b46548fcd3ff>:0
at chocolatey.infrastructure.app.services.NugetService.pack_run (chocolatey.infrastructure.app.configuration.ChocolateyConfiguration config) [0x00219] in <273947f2641b4ad5bcc7b46548fcd3ff>:0
at chocolatey.infrastructure.app.services.ChocolateyPackageService.pack_run (chocolatey.infrastructure.app.configuration.ChocolateyConfiguration config) [0x00020] in <273947f2641b4ad5bcc7b46548fcd3ff>:0
at chocolatey.infrastructure.app.commands.ChocolateyPackCommand.run (chocolatey.infrastructure.app.configuration.ChocolateyConfiguration configuration) [0x00000] in <273947f2641b4ad5bcc7b46548fcd3ff>:0
at chocolatey.infrastructure.app.runners.GenericRunner.run (chocolatey.infrastructure.app.configuration.ChocolateyConfiguration config, SimpleInjector.Container container, System.Boolean isConsole, System.Action`1[T] parseArgs) [0x000e4] in <273947f2641b4ad5bcc7b46548fcd3ff>:0
at chocolatey.infrastructure.app.runners.ConsoleApplication.run (System.String[] args, chocolatey.infrastructure.app.configuration.ChocolateyConfiguration config, SimpleInjector.Container container) [0x000d6] in <273947f2641b4ad5bcc7b46548fcd3ff>:0
at chocolatey.console.Program.Main (System.String[] args) [0x0036a] in <709fc04beb294a9288781f2c566206ab>:0
2020-07-04 09:24:25,019 30949 [DEBUG] - Exiting with 1
Full log from two runs, the first one works fine, the second run fails
2020-07-04 09:24:21,959 30944 [DEBUG] - XmlConfiguration is now operational
2020-07-04 09:24:22,010 30944 [INFO ] - ============================================================
2020-07-04 09:24:22,428 30944 [INFO ] - Chocolatey v0.10.15-129-g773b1852
2020-07-04 09:24:22,431 30944 [DEBUG] - Chocolatey is running on Linux v 5.6.0.0
2020-07-04 09:24:22,432 30944 [DEBUG] - Attempting to delete file "opt/chocolatey/console/chocolatey.dll.old".
2020-07-04 09:24:22,432 30944 [DEBUG] - Attempting to delete file "/opt/chocolatey/console/choco.exe.old".
2020-07-04 09:24:22,439 30944 [DEBUG] - Command line: /opt/chocolatey/console/choco.exe pack --allow-unofficial
2020-07-04 09:24:22,439 30944 [DEBUG] - Received arguments: pack --allow-unofficial
2020-07-04 09:24:22,472 30944 [DEBUG] - RemovePendingPackagesTask is now ready and waiting for PreRunMessage.
2020-07-04 09:24:22,481 30944 [DEBUG] - Sending message 'PreRunMessage' out if there are subscribers...
2020-07-04 09:24:22,483 30944 [DEBUG] - [Pending] Removing all pending packages that should not be considered installed...
2020-07-04 09:24:22,520 30944 [DEBUG] - Performing validation checks.
2020-07-04 09:24:22,523 30944 [DEBUG] - Global Configuration Validation Checks:
2020-07-04 09:24:22,523 30944 [DEBUG] - - Package Exit Code / Exit On Reboot = Checked
2020-07-04 09:24:22,524 30944 [DEBUG] - System State Validation Checks:
2020-07-04 09:24:22,526 30944 [INFO ] - 2 validations performed. 2 success(es), 0 warning(s), and 0 error(s).
2020-07-04 09:24:22,526 30944 [DEBUG] - The source 'https://chocolatey.org/api/v2/' evaluated to a 'normal' source type
2020-07-04 09:24:22,527 30944 [DEBUG] -
NOTE: Hiding sensitive configuration data! Please double and triple
check to be sure no sensitive data is shown, especially if copying
output to a gist for review.
2020-07-04 09:24:22,541 30944 [DEBUG] - Configuration: CommandName='pack'|CacheLocation='/tmp/chocolatey'|
ContainsLegacyPackageInstalls='True'|
CommandExecutionTimeoutSeconds='2700'|WebRequestTimeoutSeconds='30'|
Sources='https://chocolatey.org/api/v2/'|SourceType='normal'|
Debug='False'|Verbose='False'|Trace='False'|Force='False'|Noop='False'|
HelpRequested='False'|UnsuccessfulParsing='False'|RegularOutput='True'|
QuietOutput='False'|PromptForConfirmation='True'|AcceptLicense='False'|
AllowUnofficialBuild='True'|AllVersions='False'|
SkipPackageInstallProvider='False'|Prerelease='False'|ForceX86='False'|
OverrideArguments='False'|NotSilent='False'|
ApplyPackageParametersToDependencies='False'|
ApplyInstallArgumentsToDependencies='False'|IgnoreDependencies='False'|
AllowMultipleVersions='False'|AllowDowngrade='False'|
ForceDependencies='False'|Information.PlatformType='Linux'|
Information.PlatformVersion='5.6.0.0'|Information.PlatformName='Linux'|
Information.ChocolateyVersion='0.10.16.0'|
Information.ChocolateyProductVersion='0.10.15-129-g773b1852'|
Information.FullName='chocolatey, Version=0.10.16.0, Culture=neutral, PublicKeyToken=fd112f53c3ab578c'|
Information.Is64BitOperatingSystem='True'|
Information.Is64BitProcess='True'|Information.IsInteractive='False'|
Information.UserName='user'|Information.UserDomainName='debian'|
Information.IsUserAdministrator='False'|
Information.IsUserSystemAccount='False'|
Information.IsUserRemoteDesktop='False'|
Information.IsUserRemote='True'|
Information.IsProcessElevated='False'|
Information.IsLicensedVersion='False'|Information.LicenseType='Foss'|
Information.CurrentDirectory='/packages/anydesk'|
Features.AutoUninstaller='True'|Features.ChecksumFiles='True'|
Features.AllowEmptyChecksums='False'|
Features.AllowEmptyChecksumsSecure='True'|
Features.FailOnAutoUninstaller='False'|
Features.FailOnStandardError='False'|Features.UsePowerShellHost='True'|
Features.LogEnvironmentValues='False'|Features.LogWithoutColor='False'|
Features.VirusCheck='False'|
Features.FailOnInvalidOrMissingLicense='False'|
Features.IgnoreInvalidOptionsSwitches='True'|
Features.UsePackageExitCodes='True'|
Features.UseEnhancedExitCodes='False'|
Features.UseFipsCompliantChecksums='False'|
Features.ShowNonElevatedWarnings='True'|
Features.ShowDownloadProgress='True'|
Features.StopOnFirstPackageFailure='False'|
Features.UseRememberedArgumentsForUpgrades='False'|
Features.IgnoreUnfoundPackagesOnUpgradeOutdated='False'|
Features.SkipPackageUpgradesWhenNotInstalled='False'|
Features.RemovePackageInformationOnUninstall='False'|
Features.ExitOnRebootDetected='False'|
Features.LogValidationResultsOnWarnings='True'|
Features.UsePackageRepositoryOptimizations='True'|
Features.ScriptsCheckLastExitCode='False'|
ListCommand.LocalOnly='False'|
ListCommand.IdOnly='False'|ListCommand.IncludeRegistryPrograms='False'|
ListCommand.PageSize='25'|ListCommand.Exact='False'|
ListCommand.ByIdOnly='False'|ListCommand.ByTagOnly='False'|
ListCommand.IdStartsWith='False'|ListCommand.OrderByPopularity='False'|
ListCommand.ApprovedOnly='False'|
ListCommand.DownloadCacheAvailable='False'|
ListCommand.NotBroken='False'|
ListCommand.IncludeVersionOverrides='False'|
UpgradeCommand.FailOnUnfound='False'|
UpgradeCommand.FailOnNotInstalled='False'|
UpgradeCommand.NotifyOnlyAvailableUpgrades='False'|
UpgradeCommand.ExcludePrerelease='False'|
NewCommand.AutomaticPackage='False'|
NewCommand.UseOriginalTemplate='False'|SourceCommand.Command='unknown'|
SourceCommand.Priority='0'|SourceCommand.BypassProxy='False'|
SourceCommand.AllowSelfService='False'|
SourceCommand.VisibleToAdminsOnly='False'|
FeatureCommand.Command='unknown'|ConfigCommand.Command='unknown'|
ApiKeyCommand.Remove='False'|PinCommand.Command='unknown'|
OutdatedCommand.IgnorePinned='False'|Proxy.BypassOnLocal='True'|
2020-07-04 09:24:22,541 30944 [WARN ] -
Chocolatey is not an official build (bypassed with --allow-unofficial).
If you are seeing this message and it is not expected, your system may
now be in a bad state. Only official builds are to be trusted.
2020-07-04 09:24:22,541 30944 [DEBUG] - _ Chocolatey:ChocolateyPackCommand - Normal Run Mode _
2020-07-04 09:24:22,699 30944 [INFO ] - Attempting to build package from 'anydesk.nuspec'.
2020-07-04 09:24:22,818 30944 [INFO ] - Successfully created package '/packages/anydesk/anydesk.5.5.3.nupkg'
2020-07-04 09:24:22,819 30944 [DEBUG] - Sending message 'PostRunMessage' out if there are subscribers...
2020-07-04 09:24:22,821 30944 [DEBUG] - Exiting with 0
2020-07-04 09:24:24,211 30949 [DEBUG] - XmlConfiguration is now operational
2020-07-04 09:24:24,261 30949 [INFO ] - ============================================================
2020-07-04 09:24:24,675 30949 [INFO ] - Chocolatey v0.10.15-129-g773b1852
2020-07-04 09:24:24,678 30949 [DEBUG] - Chocolatey is running on Linux v 5.6.0.0
2020-07-04 09:24:24,679 30949 [DEBUG] - Attempting to delete file "opt/chocolatey/console/chocolatey.dll.old".
2020-07-04 09:24:24,679 30949 [DEBUG] - Attempting to delete file "/opt/chocolatey/console/choco.exe.old".
2020-07-04 09:24:24,686 30949 [DEBUG] - Command line: /opt/chocolatey/console/choco.exe pack --allow-unofficial
2020-07-04 09:24:24,686 30949 [DEBUG] - Received arguments: pack --allow-unofficial
2020-07-04 09:24:24,720 30949 [DEBUG] - RemovePendingPackagesTask is now ready and waiting for PreRunMessage.
2020-07-04 09:24:24,729 30949 [DEBUG] - Sending message 'PreRunMessage' out if there are subscribers...
2020-07-04 09:24:24,731 30949 [DEBUG] - [Pending] Removing all pending packages that should not be considered installed...
2020-07-04 09:24:24,766 30949 [DEBUG] - Performing validation checks.
2020-07-04 09:24:24,769 30949 [DEBUG] - Global Configuration Validation Checks:
2020-07-04 09:24:24,770 30949 [DEBUG] - - Package Exit Code / Exit On Reboot = Checked
2020-07-04 09:24:24,770 30949 [DEBUG] - System State Validation Checks:
2020-07-04 09:24:24,772 30949 [INFO ] - 2 validations performed. 2 success(es), 0 warning(s), and 0 error(s).
2020-07-04 09:24:24,773 30949 [DEBUG] - The source 'https://chocolatey.org/api/v2/' evaluated to a 'normal' source type
2020-07-04 09:24:24,773 30949 [DEBUG] -
NOTE: Hiding sensitive configuration data! Please double and triple
check to be sure no sensitive data is shown, especially if copying
output to a gist for review.
2020-07-04 09:24:24,787 30949 [DEBUG] - Configuration: CommandName='pack'|CacheLocation='/tmp/chocolatey'|
ContainsLegacyPackageInstalls='True'|
CommandExecutionTimeoutSeconds='2700'|WebRequestTimeoutSeconds='30'|
Sources='https://chocolatey.org/api/v2/'|SourceType='normal'|
Debug='False'|Verbose='False'|Trace='False'|Force='False'|Noop='False'|
HelpRequested='False'|UnsuccessfulParsing='False'|RegularOutput='True'|
QuietOutput='False'|PromptForConfirmation='True'|AcceptLicense='False'|
AllowUnofficialBuild='True'|AllVersions='False'|
SkipPackageInstallProvider='False'|Prerelease='False'|ForceX86='False'|
OverrideArguments='False'|NotSilent='False'|
ApplyPackageParametersToDependencies='False'|
ApplyInstallArgumentsToDependencies='False'|IgnoreDependencies='False'|
AllowMultipleVersions='False'|AllowDowngrade='False'|
ForceDependencies='False'|Information.PlatformType='Linux'|
Information.PlatformVersion='5.6.0.0'|Information.PlatformName='Linux'|
Information.ChocolateyVersion='0.10.16.0'|
Information.ChocolateyProductVersion='0.10.15-129-g773b1852'|
Information.FullName='chocolatey, Version=0.10.16.0, Culture=neutral, PublicKeyToken=fd112f53c3ab578c'|
Information.Is64BitOperatingSystem='True'|
Information.Is64BitProcess='True'|Information.IsInteractive='False'|
Information.UserName='user'|Information.UserDomainName='debian'|
Information.IsUserAdministrator='False'|
Information.IsUserSystemAccount='False'|
Information.IsUserRemoteDesktop='False'|
Information.IsUserRemote='True'|
Information.IsProcessElevated='False'|
Information.IsLicensedVersion='False'|Information.LicenseType='Foss'|
Information.CurrentDirectory='/packages/anydesk'|
Features.AutoUninstaller='True'|Features.ChecksumFiles='True'|
Features.AllowEmptyChecksums='False'|
Features.AllowEmptyChecksumsSecure='True'|
Features.FailOnAutoUninstaller='False'|
Features.FailOnStandardError='False'|Features.UsePowerShellHost='True'|
Features.LogEnvironmentValues='False'|Features.LogWithoutColor='False'|
Features.VirusCheck='False'|
Features.FailOnInvalidOrMissingLicense='False'|
Features.IgnoreInvalidOptionsSwitches='True'|
Features.UsePackageExitCodes='True'|
Features.UseEnhancedExitCodes='False'|
Features.UseFipsCompliantChecksums='False'|
Features.ShowNonElevatedWarnings='True'|
Features.ShowDownloadProgress='True'|
Features.StopOnFirstPackageFailure='False'|
Features.UseRememberedArgumentsForUpgrades='False'|
Features.IgnoreUnfoundPackagesOnUpgradeOutdated='False'|
Features.SkipPackageUpgradesWhenNotInstalled='False'|
Features.RemovePackageInformationOnUninstall='False'|
Features.ExitOnRebootDetected='False'|
Features.LogValidationResultsOnWarnings='True'|
Features.UsePackageRepositoryOptimizations='True'|
Features.ScriptsCheckLastExitCode='False'|
ListCommand.LocalOnly='False'|
ListCommand.IdOnly='False'|ListCommand.IncludeRegistryPrograms='False'|
ListCommand.PageSize='25'|ListCommand.Exact='False'|
ListCommand.ByIdOnly='False'|ListCommand.ByTagOnly='False'|
ListCommand.IdStartsWith='False'|ListCommand.OrderByPopularity='False'|
ListCommand.ApprovedOnly='False'|
ListCommand.DownloadCacheAvailable='False'|
ListCommand.NotBroken='False'|
ListCommand.IncludeVersionOverrides='False'|
UpgradeCommand.FailOnUnfound='False'|
UpgradeCommand.FailOnNotInstalled='False'|
UpgradeCommand.NotifyOnlyAvailableUpgrades='False'|
UpgradeCommand.ExcludePrerelease='False'|
NewCommand.AutomaticPackage='False'|
NewCommand.UseOriginalTemplate='False'|SourceCommand.Command='unknown'|
SourceCommand.Priority='0'|SourceCommand.BypassProxy='False'|
SourceCommand.AllowSelfService='False'|
SourceCommand.VisibleToAdminsOnly='False'|
FeatureCommand.Command='unknown'|ConfigCommand.Command='unknown'|
ApiKeyCommand.Remove='False'|PinCommand.Command='unknown'|
OutdatedCommand.IgnorePinned='False'|Proxy.BypassOnLocal='True'|
2020-07-04 09:24:24,787 30949 [WARN ] -
Chocolatey is not an official build (bypassed with --allow-unofficial).
If you are seeing this message and it is not expected, your system may
now be in a bad state. Only official builds are to be trusted.
2020-07-04 09:24:24,788 30949 [DEBUG] - _ Chocolatey:ChocolateyPackCommand - Normal Run Mode _
2020-07-04 09:24:24,943 30949 [INFO ] - Attempting to build package from 'anydesk.nuspec'.
2020-07-04 09:24:25,016 30949 [DEBUG] - Sending message 'PostRunMessage' out if there are subscribers...
2020-07-04 09:24:25,018 30949 [ERROR] - This partUri is already contained in the package
2020-07-04 09:24:25,019 30949 [ERROR] - More Details: System.InvalidOperationException: This partUri is already contained in the package
at System.IO.Packaging.Package.CreatePart (System.Uri partUri, System.String contentType, System.IO.Packaging.CompressionOption compressionOption) [0x0001b] in <a0ec8c343cb4418c9a045f20ad533b4e>:0
at NuGet.PackageBuilder.WriteManifest (System.IO.Packaging.Package package, System.Int32 minimumManifestVersion) [0x00024] in <23136ac9008c43ea82679714836f769c>:0
at NuGet.PackageBuilder.Save (System.IO.Stream stream) [0x000c5] in <23136ac9008c43ea82679714836f769c>:0
at chocolatey.infrastructure.app.nuget.NugetPack.BuildPackage (NuGet.PackageBuilder builder, chocolatey.infrastructure.filesystem.IFileSystem fileSystem, System.String outputPath) [0x00044] in <273947f2641b4ad5bcc7b46548fcd3ff>:0
at chocolatey.infrastructure.app.services.NugetService.pack_run (chocolatey.infrastructure.app.configuration.ChocolateyConfiguration config) [0x00219] in <273947f2641b4ad5bcc7b46548fcd3ff>:0
at chocolatey.infrastructure.app.services.ChocolateyPackageService.pack_run (chocolatey.infrastructure.app.configuration.ChocolateyConfiguration config) [0x00020] in <273947f2641b4ad5bcc7b46548fcd3ff>:0
at chocolatey.infrastructure.app.commands.ChocolateyPackCommand.run (chocolatey.infrastructure.app.configuration.ChocolateyConfiguration configuration) [0x00000] in <273947f2641b4ad5bcc7b46548fcd3ff>:0
at chocolatey.infrastructure.app.runners.GenericRunner.run (chocolatey.infrastructure.app.configuration.ChocolateyConfiguration config, SimpleInjector.Container container, System.Boolean isConsole, System.Action`1[T] parseArgs) [0x000e4] in <273947f2641b4ad5bcc7b46548fcd3ff>:0
at chocolatey.infrastructure.app.runners.ConsoleApplication.run (System.String[] args, chocolatey.infrastructure.app.configuration.ChocolateyConfiguration config, SimpleInjector.Container container) [0x000d6] in <273947f2641b4ad5bcc7b46548fcd3ff>:0
at chocolatey.console.Program.Main (System.String[] args) [0x0036a] in <709fc04beb294a9288781f2c566206ab>:0
2020-07-04 09:24:25,019 30949 [DEBUG] - Exiting with 1
This partUri is already contained in the package
This is a strange error. I don't think that is how it should be reacting. When it can't overwrite a file, it should be sending a different message.
So, I've been debugging this, it's been painful to get working on Linux...
The pack fails at NuGet.PackageBuilder.WriteManifest called from NuGet.PackageBuilder.Save.
The issue actually comes in a few lines earlier, when System.IO.Packaging.Package.Open is called. It is called with FileMode.Create
, which should truncate the file if the file already exists.
However, the file is not getting truncated properly, so it reads in the previously existing values from current .nupkg
when run on Mono:
While if I run it on Windows, the file is truncated properly, and the previous existing values are discarded:
Therefore, it appears like there is an issue with System.IO.Packaging.Package.Open
on Mono.
I've opened an issue with Mono, after some more testing:
mono/mono#21055