ScoopInstaller / Main

📦 The default bucket for Scoop.
https://scoop.sh
The Unlicense
1.54k stars 921 forks source link

[Bug]: Error when trying to install azure-cli #5300

Closed ahrib closed 5 months ago

ahrib commented 7 months ago

Prerequisites

Package Name

azure-cli

Expected/Current Behaviour

Current behaviour Having a problem updating or installing the azure-cli package (2.54.0 at time of writing). The last successful version of the package I was able to install was version 2.51.0

The error I receive from the azure-cli installer is "Error writing to file: C:\users\XXXXXXXX\scoop\apps\azure-cli\2.54.0_tmp\SourceDir\Microsoft SDKs\Azure\SLI2\Lib\site-packages\azure\cli\command_modules\dla\vendored_sdks\azure_mgmt_datalake_analytics\catalog\models\data_lake_analytics_catalog_secret_create_or_update_parameters.pyc"

The Log file referenced by scoop does not exist. (~\scoop\apps\azure-cli\2.54.0\msi.log)

Steps to Reproduce

PS> scoop install azure-cli
Installing 'azure-cli' (2.54.0) [64bit] from main bucket
Loading azure-cli-2.54.0.msi from cache
Checking hash of azure-cli-2.54.0.msi ... ok.
Extracting azure-cli-2.54.0.msi ... ERROR Exit code was 1603!
Failed to extract files from C:\Users\xxxxxxxx\scoop\apps\azure-cli\2.54.0\azure-cli-2.54.0.msi.
Log file:
  ~\scoop\apps\azure-cli\2.54.0\msi.log

Please try again or create a new issue by using the following link and paste your console output:
https://github.com/ScoopInstaller/Main/issues/new?title=azure-cli%402.54.0%3a+decompress+error

Possible Solution

The error I receive from the installer (see current behaviour section) references a very long file path.. possible solution is to change the temp folder where the MSI is extracted to a shorter path

Scoop and Buckets Version

PS>  scoop --version
Current Scoop version:
v0.3.1 - Released at 2022-11-15

'extras' bucket:
49f53d59c (HEAD -> master, origin/master, origin/HEAD) vivaldi: Update to version 6.4.3160.47

'main' bucket:
e84554454 (HEAD -> master, origin/master, origin/HEAD) ripgrep: Update to version 14.0.3

Scoop Config

PS> scoop config

aria2-enabled : False
aria2-options : {--check-certificate=false}
proxy         :
last_update   : 29/11/2023 2:17:11 PM
scoop_branch  : master
scoop_repo    : https://github.com/ScoopInstaller/Scoop

PowerShell Version

PS> $PSVersiontable

Name                           Value
----                           -----
PSVersion                      7.4.0
PSEdition                      Core
GitCommitId                    7.4.0
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Additional Softwares

No response

rob-spoor commented 7 months ago

I have the same issue on one machine but not on another. The difference is the username - 6 characters where it works, 9 where it doesn't. The file it complains about is 261 characters: C:\Users\xxxxxxxxx\scoop\apps\azure-cli\2.55.0\_tmp\SourceDir\Microsoft SDKs\Azure\CLI2\Lib\site-packages\azure\cli\command_modules\dla\vendored_sdks\azure_mgmt_datalake_analytics\catalog\models\data_lake_analytics_catalog_secret_create_or_update_parameters.pyc. And no, I cannot change my username.

rob-spoor commented 7 months ago

I managed to install version 2.55.0 by changing decompress.ps1:

    if ($ExtractDir) {
        $OriDestinationPath = $DestinationPath
        #$DestinationPath = "$DestinationPath\_tmp"
        $DestinationPath = "$env:TMP\scoop"
    }
abatishchev commented 7 months ago

Same error for me

HUMORCE commented 5 months ago
> scoop checkup
WARN  LongPaths support is not enabled.
  You can enable it by running:
    sudo Set-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -Value 1
  (Requires 'sudo' command. Run 'scoop install sudo' if you don't have it.)

Would a enabled long path support solve this issue? OR scoop config use_lessmsi true; scoop install azure-cli; scoop config use_lessmsi false

ahrib commented 5 months ago

Hi appreciate the suggestions.

LongPaths support is disabled by my organization and I am unable to change this.

running scoop config use_lessmsi true; scoop install azure-cli; scoop config use_lessmsi false (note use of azure-cli not aws-sam-cli) installed the tool successfully - good workaround.

I like rob-spoor's approach as well in the comment https://github.com/ScoopInstaller/Main/issues/5300#issuecomment-1840812098

HUMORCE commented 5 months ago

running scoop config use_lessmsi true; scoop install azure-cli; scoop config use_lessmsi false (note use of azure-cli not aws-sam-cli) installed the tool successfully - good workaround.

emmmm, I was working on another issue at the time and got confused.

I like rob-spoor's approach as well in the comment https://github.com/ScoopInstaller/Main/issues/5300#issuecomment-1840812098

Yes, it is works, but may caused performance issue (when moving extracted files), if users installs Scoop to another disk instead of disk of system partition. And changes to Core code may cause Scoop's self-update fail when next release published.

rashil2000 commented 5 months ago

The official fix for this is enabling LongPath support, if not, using LessMSI as commented earlier.

Closing the issue in this light.

o-l-a-v commented 2 months ago

Azure CLI is also released as a ZIP package now, but then only for x64.

What about changing the manifest to use ZIP instead? Or add a azure-cli-zip.json manifest?


Edit: Here's a manifest that seems do work at least for installation. Filename azure-cli-zip.json.

{
  "version": "2.60.0",
  "description": "A cross-platform command-line tool to connect to Azure and execute administrative commands on Azure resources",
  "homepage": "https://aka.ms/cli",
  "license": "MIT",
  "notes": [
    "* Known issue:",
    "  - Cannot be extracted due to long path: https://github.com/ScoopInstaller/Main/issues/5300"
  ],
  "architecture": {
    "64bit": {
      "url": "https://azcliprod.blob.core.windows.net/zip/azure-cli-2.60.0-x64.zip",
      "hash": "40891711b9cc31693df7445db5236f8c7a6cae851f9087cace0e0186781a6a73"
    }
  },
  "env_set": {
    "AZURE_CLI_PATH": "$dir\\bin",
    "AzureCLIPath": "$dir\\bin"
  },
  "bin": "bin\\az.cmd",
  "checkver": {
    "github": "https://github.com/Azure/azure-cli",
    "regex": "/releases/tag/azure-cli-([\\d.]+)"
  },
  "autoupdate": {
    "architecture": {
      "64bit": {
        "url": "https://azcliprod.blob.core.windows.net/zip/azure-cli-$version-x64.zip"
      }
    }
  }
}

A PowerShell command to chech whether long paths has been enabled, could be used in post_install maybe?

[bool](
    (Get-ItemPropertyValue -Path 'Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem' -Name 'LongPathsEnabled' -ErrorAction 'Ignore') -eq 1
)