msys2-installer icon indicating copy to clipboard operation
msys2-installer copied to clipboard

Install via chocolatey does not work

Open AMDphreak opened this issue 4 years ago • 11 comments

First attempt

Hangs on confirm dialog:

msys2 v20200720.0.0 [Approved]
msys2 package files install completed. Performing other installation steps.
The package msys2 wants to run 'chocolateyinstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation

I cannot type any response to the prompt, and it will not go away.

force reinstall

Force reinstall fails. Possibly a separate bug, but who cares? I wanted one thing to just work, now I have three things that just do not.

PS C:\Windows\system32> choco install msys2
Chocolatey v0.10.15
Installing the following packages:
msys2
By installing you accept licenses for the packages.
msys2 v20200720.0.0 already installed.
 Use --force to reinstall, specify a version to install, or try upgrade.

Chocolatey installed 0/1 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Warnings:
 - msys2 - msys2 v20200720.0.0 already installed.
 Use --force to reinstall, specify a version to install, or try upgrade.
PS C:\Windows\system32> choco install msys2 --force
Chocolatey v0.10.15
Installing the following packages:
msys2
By installing you accept licenses for the packages.
msys2 v20200720.0.0 already installed. Forcing reinstall of version '20200720.0.0'.
 Please use upgrade if you meant to upgrade to a new version.
This is try 1/3. Retrying after 300 milliseconds.
 Error converted to warning:
 (5) Access is denied: [\\?\C:\ProgramData\chocolatey\lib-bkp\msys2]
This is try 2/3. Retrying after 400 milliseconds.
 Error converted to warning:
 (5) Access is denied: [\\?\C:\ProgramData\chocolatey\lib-bkp\msys2]
Maximum tries of 3 reached. Throwing error.
This is try 1/3. Retrying after 300 milliseconds.
 Error converted to warning:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib-bkp\msys2\.chocolateyPending]
This is try 2/3. Retrying after 400 milliseconds.
 Error converted to warning:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib-bkp\msys2\.chocolateyPending]
Maximum tries of 3 reached. Throwing error.
Error during backup (move phase):
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib-bkp\msys2\.chocolateyPending]
There was an error accessing files. This could mean there is a
 process locking the folder or files. Please make sure nothing is
 running that would lock the files or folders in this directory prior
 to upgrade. If the package fails to upgrade, this is likely the cause.
[NuGet] Uninstalling 'msys2 20200720.0.0' might cause 'haskell-dev 0.0.1' to be broken.
This is try 1/3. Retrying after 300 milliseconds.
 Error converted to warning:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib\msys2\.chocolateyPending]
This is try 2/3. Retrying after 400 milliseconds.
 Error converted to warning:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib\msys2\.chocolateyPending]
Maximum tries of 3 reached. Throwing error.
Unable to remove existing package prior to forced reinstall:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib\msys2\.chocolateyPending]

msys2 v20200720.0.0 (forced) [Approved]
msys2 not installed. An error occurred during installation:
 The process cannot access the file 'C:\ProgramData\chocolatey\lib\msys2\.chocolateyPending' because it is being used by another process.

Chocolatey installed 0/0 packages.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).
The process cannot access the file 'C:\ProgramData\chocolatey\lib\msys2\.chocolateyPending' because it is being used by another process.

image

Second attempt

PS C:\Windows\system32> choco install msys2
Chocolatey v0.10.15
Installing the following packages:
msys2
By installing you accept licenses for the packages.
Progress: Downloading msys2 20200720.0.0... 100%

msys2 v20200720.0.0 [Approved]
msys2 package files install completed. Performing other installation steps.
The package msys2 wants to run 'chocolateyinstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint): A

'C:\tools\msys64' already exists and will only be updated.
Invoking first run to setup things like bash profile, gpg etc...
Invoking msys2 shell command: -defterm -no-start -c "ps -ef | grep '[?]' | awk '{print $2}' | xargs -r kill"
ERROR: This command cannot be run due to the error: The system cannot find the file specified.
The install of msys2 was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\msys2\tools\chocolateyinstall.ps1'.
 See log for details.

Chocolatey installed 0/1 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures
 - msys2 (exited -1) - Error while running 'C:\ProgramData\chocolatey\lib\msys2\tools\chocolateyinstall.ps1'.
 See log for details.

image

I think this is the key phrase (copied from log):

2020-07-26 01:41:15,992 12880 [INFO ] - Invoking first run to setup things like bash profile, gpg etc...
2020-07-26 01:41:16,001 12880 [INFO ] - Invoking msys2 shell command: -defterm -no-start -c "ps -ef | grep '[?]' | awk '{print $2}' | xargs -r kill"
2020-07-26 01:41:16,035 12880 [ERROR] - ERROR: This command cannot be run due to the error: The system cannot find the file specified.

Deleted folder then tried reinstalling

deleted C:\tools\msys64

PS C:\WINDOWS\system32> choco install msys2
Chocolatey v0.10.15
Installing the following packages:
msys2
By installing you accept licenses for the packages.
Progress: Downloading msys2 20200720.0.0... 100%

msys2 v20200720.0.0 [Approved]
msys2 package files install completed. Performing other installation steps.
The package msys2 wants to run 'chocolateyinstall.ps1'.
Note: If you don't run this script, the installation will fail.
Note: To confirm automatically next time, use '-y' or consider:
choco feature enable -n allowGlobalConfirmation
Do you want to run the script?([Y]es/[A]ll - yes to all/[N]o/[P]rint): y

Installing to: C:\tools\msys64
Extracting 64-bit C:\ProgramData\chocolatey\lib\msys2\tools\msys2-base-x86_64-20200720.tar.xz to C:\tools\msys64...
C:\tools\msys64
Extracting C:\tools\msys64\msys2-base-x86_64-20200720.tar to C:\tools\msys64...
C:\tools\msys64
ERROR: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Access to the path 'C:\tools\msys64\msys64\usr' is denied.
The install of msys2 was NOT successful.
Error while running 'C:\ProgramData\chocolatey\lib\msys2\tools\chocolateyinstall.ps1'.
 See log for details.

Chocolatey installed 0/1 packages. 1 packages failed.
 See the log for details (C:\ProgramData\chocolatey\logs\chocolatey.log).

Failures
 - msys2 (exited -1) - Error while running 'C:\ProgramData\chocolatey\lib\msys2\tools\chocolateyinstall.ps1'.
 See log for details.

image

Administrator has full control over the folder that the script claims it cannot access: image

Error Log:

2020-07-26 18:10:55,373 880 [INFO ] - C:\tools\msys64
2020-07-26 18:10:55,420 880 [ERROR] - ERROR: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: Access to the path 'C:\tools\msys64\msys64\usr' is denied.
2020-07-26 18:10:55,422 880 [DEBUG] - Built-in PowerShell host called with ['[System.Threading.Thread]::CurrentThread.CurrentCulture = '';[System.Threading.Thread]::CurrentThread.CurrentUICulture = ''; & import-module -name 'C:\ProgramData\chocolatey\helpers\chocolateyInstaller.psm1'; & 'C:\ProgramData\chocolatey\helpers\chocolateyScriptRunner.ps1' -packageScript 'C:\ProgramData\chocolatey\lib\msys2\tools\chocolateyinstall.ps1' -installArguments '' -packageParameters '''] exited with '-1'.

Non-existent msys2_shell.cmd

I have suspended the install process (by not answering the prompt) in order to inspect the folder contents. Your script's function contains FilePath = Join-Path $InstallPath msys2_shell.cmd . There is no such thing as msys2_shell.cmd.

function Invoke-Msys2Shell($Arguments) {
    if (![string]::IsNullOrWhiteSpace($Arguments)) { $Arguments += "; " }
    $Arguments += "ps -ef | grep '[?]' | awk '{print `$2}' | xargs -r kill"

    $params = @{
        FilePath     = Join-Path $InstallPath msys2_shell.cmd
        NoNewWindow  = $true
        Wait         = $true
        ArgumentList = "-defterm", "-no-start", "-c", "`"$Arguments`""
    }
    Write-Host "Invoking msys2 shell command:" $params.ArgumentList
    Start-Process @params
}

Also there appears to be a typo: ArgumentList = "-defterm", "-no-start", "-c", "`"$Arguments`"" has "`"$Arguments`"" which clearly can't be correct. Either you're trying to quote the output of a variable or you're trying to use a variable that includes quotes, which seems unlikely since $, not "$, denotes a variable.

image

Install-Msys2 function bugged

Install-Msys2 function skips un-tarring the archive when it needs to do that to detect msys2_shell.cmd later.

function Install-Msys2 {
    if (Test-Path $InstallPath) { 
        Write-Host "'$InstallPath' already exists and will only be updated."
        return 
    }

    Write-Host "Installing to:" $InstallPath
    $packageArgs = @{
        PackageName    = $Env:ChocolateyPackageName
        FileFullPath   = Get-Item $ToolsPath\*-i686*
        FileFullPath64 = Get-Item $ToolsPath\*-x86_64*
        Destination    = $InstallPath
    }
    Get-ChocolateyUnzip @packageArgs
    Remove-Item $ToolsPath\*.xz -ea 0

    $tarFile = Get-Item "$InstallPath\*.tar"
    Get-ChocolateyUnzip $tarFile $InstallPath
    Remove-Item "$InstallPath\*.tar" -ea 0
    $tardir = Get-Item "$InstallPath\msys*"
    if ([String]::IsNullOrWhiteSpace($tardir)) { throw "Can't find msys* directory from tar archive" }
    Move-Item $tardir\* $InstallPath
    Remove-Item $tardir
}

Script looks in wrong folder. Needs to look deeper

If $InstallPath is "C:\tools\msys64" instead of the temporary installation files folder (ProgramData\chocolatey...), then it is highly likely that your script is looking in the wrong folder. msys2_shell.cmd is located at "C:\tools\msys64\msys64\msys2_shell.cmd" --not "C:\tools\msys64\msys2_shell.cmd" image

It would be nice to be able to SEE what the damn value of $InstallPath is. Any script that runs on a user's computer should have an IDE installed that will simulate the runtime and visualize the state of variables so people aren't stuck here making guesses what the variable is.

I am not a chocolatey maintainer. I should not be debugging this or reading ps1 scripts just to get MSYS2 installed. This is utterly ridiculous.

And this further proves why file systems should not be hierarchical i-node-based namespaces.

AMDphreak avatar Jul 25 '20 12:07 AMDphreak

Note that we don't maintain the choco package and the scripts you mention. But it would be nice if it worked, so maybe you can report this to choco? (feel free to leave this open and just link to this issue if it makes things easier)

lazka avatar Jul 29 '20 07:07 lazka

Note that we don't maintain the choco package and the scripts you mention. But it would be nice if it worked, so maybe you can report this to choco? (feel free to leave this open and just link to this issue if it makes things easier)

Hi, thanks. Does Chocolatey write install scripts for every package? That doesn't seem likely to me.

AMDphreak avatar Aug 14 '20 00:08 AMDphreak

That's basically what a choco package is, install/upgrade/uninstall scripts.

lazka avatar Aug 14 '20 05:08 lazka

That's basically what a choco package is, install/upgrade/uninstall scripts.

I was asking if their organization itself wrote the scripts. They have community packages, so the answer is no.

AMDphreak avatar Oct 04 '20 20:10 AMDphreak

@AMDphreak I believe that the organization (should I say company?) does moderate 'community packages': https://chocolatey.org/docs/moderation

They certainly distribute these packages and therefore must take some level of responsibility for their quality.

mingwandroid avatar Oct 04 '20 21:10 mingwandroid

@AMDphreak If your assumption about the script is right, (I don't know anything about powershell script) then probably you should create issue in this repository. You can get the link by clicking Package Source at the left of the site of chocolatey package.

CookieHCl avatar Oct 06 '20 12:10 CookieHCl

It installed for me on my first try, can you reproduce it on a clean Windows install and a recent chocolatey version?

chayleaf avatar Oct 18 '20 18:10 chayleaf

It installed for me on my first try, can you reproduce it on a clean Windows install and a recent chocolatey version?

I'm not reinstalling Windows just for this. Also, what are the odds that other people are going to re-install Windows just for this? My installation is fairly run of the mill. I've avoided installing any non-legitimate software, and it is a legitimate license for Windows. All system settings are pretty much default. If MSYS and Chocolatey are choking on their own legacy configuration files, upgrade consistency is their problem and responsibility.

Problems like this are why I hate hierarchical file systems. File paths are obtuse to use. The things that should be unique (what file is used by a program) aren't unique, and the things that shouldn't be unique (where the file exists) are. Abusing the file path to indicate a different purpose of a file (i.e. a different version or association with whatever program it should be used with) is stupid.

AMDphreak avatar Oct 29 '20 06:10 AMDphreak

@AMDphreak, as an alternative to opening an issue in a repository corresponding to chocolatey, you might want to use https://github.com/msys2/msys2-installer/releases/download/2020-09-03/msys2-x86_64-20200903.exe (which is the supported procedure in this repo).

eine avatar Nov 09 '20 16:11 eine

@AMDphreak, as an alternative to opening an issue in a repository corresponding to chocolatey, you might want to use https://github.com/msys2/msys2-installer/releases/download/2020-09-03/msys2-x86_64-20200903.exe (which is the supported procedure in this repo).

I appreciate it!

AMDphreak avatar Nov 12 '20 03:11 AMDphreak

JFYTK, you can extract/install it unattended with msys2-x86_64-20200903.exe -y target_location.

eine avatar Nov 12 '20 04:11 eine