chocolatey / chocolatey/choco

fileType parameter's default value should not be EXE in params block

Open
#3,095 0 comments 1 reaction 0 assignees View on GitHub
0 - Triaging Bug
Dominant language
C#
Stars
11.5k
Forks
960
PR merge metrics
No merged PRs in 30d

Description

### Checklist

- [X] I have verified this is the correct repository for opening this issue.
- [X] I have verified no other issues exist related to my problem.
- [X] I have verified this is not an issue for a specific package.
- [X] I have verified this issue is not security related.

### What You Are Seeing?

Unless you pass 'fileType' as NULL or empty string to Install-ChocolateyInstallPackage.ps1, choco doesn't try to detect the fileType automatically based on file extension.

this is beacuse the default value is set to EXE in params block.
`[alias("installerType", "installType")][string] $fileType = 'exe',`

### What is Expected?

when fileType is not passed i.e. when parameter is skipped in call to Install-ChocolateyInstallPackage/ Install-ChocolateyPackage , choco detects it based on file extension. This is what the documentation appears to be saying.

> .PARAMETER FileType
This is the extension of the file. This can be 'exe', 'msi', or 'msu'.
Licensed editions of Chocolatey use this to automatically determine
silent arguments. If this is not provided, Chocolatey will
automatically determine this using the downloaded file's extension.

### How Did You Get This To Happen?

tried to install a MSI and called Install-ChocolateyPackage without specifying fileType parameter. file path was passed in.

1. create a new package which install MSI
2. in ChoclateyInstall.ps1, call Install-ChocolateyPackage with uri and file location, but don't specify fileType='MSI'
3. package using choco package
4. try to install the package.

It will give un-related error complaining file is not suitable for OS.

### System Details

* Operating System: Win 2016
* Windows PowerShell version: 5.1
* Chocolatey CLI Version: all versions
* Chocolatey Licensed Extension version:
* Chocolatey License type:
* Terminal/Emulator: cmd

### Installed Packages

```bash
N/A
```

### Output Log

```bash
N/A
```

### Additional Context

check https://github.com/chocolatey/choco/blob/develop/src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1
the logic below gets called only when the fileType is passed as NULL/EMPTY and not when it's skipped.

` if ($fileType -eq '' -or $fileType -eq $null) {
Write-Debug 'No FileType supplied. Using the file extension to determine FileType'
$fileType = [System.IO.Path]::GetExtension("$fileFullPath").Replace(".", "")
}

$installerTypeLower = $fileType.ToLower()
if ('msi', 'exe', 'msu', 'msp' -notcontains $installerTypeLower) {
Write-Warning "FileType '$fileType' is unrecognized, using 'exe' instead."
$fileType = 'exe'
}`

Contributor guide

Open the contributing guide

Research direction

Start in src/chocolatey.resources/helpers/functions/Install-ChocolateyInstallPackage.ps1 and inspect the params block for the fileType default. Reproduce the omitted-fileType MSI installation described in the issue, then verify that file-extension detection runs and the installation succeeds without explicitly passing fileType.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.