rmyorston / busybox-w32

WIN32 native port of BusyBox.
https://frippery.org/busybox
Other
674 stars 124 forks source link

choco and busybox64 interact poorly to prevent installation of choco packages; powershell works correctly #362

Closed doctorpangloss closed 1 year ago

doctorpangloss commented 1 year ago

Reproduction:

  1. In an administrative powershell shell, try installing multiple choco packages:

    choco install -y awscli crane eksctl --force

    Observe this completes successfully.

  2. In an administrative busybox sh shell, try installing multiple choco packages:

choco install -y awscli crane eksctl --force

Observe the following failures:

~ # choco install -y awscli crane eksctl --force
Chocolatey v2.2.2
Installing the following packages:
awscli;crane;eksctl
By installing, you accept licenses for the packages.
awscli v2.13.13 already installed. Forcing reinstall of version '2.13.13'.
 Please use upgrade if you meant to upgrade to a new version.
Progress: Downloading awscli 2.13.13... 100%

awscli v2.13.13 (forced) [Approved]
awscli package files install completed. Performing other installation steps.
Downloading awscli 64 bit
  from 'https://awscli.amazonaws.com/AWSCLIV2-2.13.13.msi'
Progress: 100% - Completed download of C:\Users\bberman\AppData\Local\Temp\chocolatey\awscli\2.13.13\AWSCLIV2-2.13.13.msi (36.82 MB).
Download of AWSCLIV2-2.13.13.msi (36.82 MB) completed.
Hashes match.
Installing awscli...
awscli has been installed.
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\awscli\.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\awscli\.chocolateyPending]
Maximum tries of 3 reached. Throwing error.
Attempted to delete bad package install path if existing. Had an error:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib\awscli\.chocolateyPending]
 The install of awscli was successful.
  Software installed as 'MSI', install location is likely default.
crane v0.2.0.15 already installed. Forcing reinstall of version '0.2.0.15'.
 Please use upgrade if you meant to upgrade to a new version.
Progress: Downloading crane 0.2.0.15... 100%

crane v0.2.0.15 (forced) [Approved]
crane package files install completed. Performing other installation steps.
 ShimGen has successfully created a shim for crane.exe
 ShimGen has successfully created a shim for NuGet.exe
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\crane\.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\crane\.chocolateyPending]
Maximum tries of 3 reached. Throwing error.
Attempted to delete bad package install path if existing. Had an error:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib\crane\.chocolateyPending]
 The install of crane was successful.
  Software installed to 'C:\ProgramData\chocolatey\lib\crane'
eksctl v0.154.0 already installed. Forcing reinstall of version '0.154.0'.
 Please use upgrade if you meant to upgrade to a new version.
Progress: Downloading eksctl 0.154.0... 100%

eksctl v0.154.0 (forced) [Approved]
eksctl package files install completed. Performing other installation steps.
eksctl is going to be installed in 'C:\ProgramData\chocolatey\lib\eksctl\tools'
Downloading eksctl 64 bit
  from 'https://github.com/eksctl-io/eksctl/releases/download/v0.154.0/eksctl_Windows_amd64.zip'
Progress: 100% - Completed download of C:\Users\bberman\AppData\Local\Temp\chocolatey\eksctl\0.154.0\eksctl_Windows_amd64.zip (33.1 MB).
Download of eksctl_Windows_amd64.zip (33.1 MB) completed.
Hashes match.
Extracting C:\Users\bberman\AppData\Local\Temp\chocolatey\eksctl\0.154.0\eksctl_Windows_amd64.zip to C:\ProgramData\chocolatey\lib\eksctl\tools...
C:\ProgramData\chocolatey\lib\eksctl\tools
 ShimGen has successfully created a shim for eksctl.exe
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\eksctl\.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\eksctl\.chocolateyPending]
Maximum tries of 3 reached. Throwing error.
Attempted to delete bad package install path if existing. Had an error:
 (32) The process cannot access the file because it is being used by another process: [\\?\C:\ProgramData\chocolatey\lib\eksctl\.chocolateyPending]
 The install of eksctl was successful.
  Software installed to 'C:\ProgramData\chocolatey\lib\eksctl\tools'

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

Busybox version: BusyBox v1.37.0-PRE-5188-gac9ff15e2 (2023-08-24 16:01:05 BST) Choco version: 2.2.2\

Note that despite the logs, the installation was not successful.

rmyorston commented 1 year ago

This seems to be one of those edge cases where something in Windows takes exception to forward slashes in environment variables.

Try starting your shell with the -X option or -o winxp. Or put set -o winxp in your .profile.

doctorpangloss commented 1 year ago

sh -X resolves the issue. But do I really want to run with that? I feel like this will break my shell scripts which use forward slashes everywhere.

doctorpangloss commented 1 year ago

If you can give me an insight as to what should be fixed in choco I'll ticket it there.

rmyorston commented 1 year ago

sh -X resolves the issue. But do I really want to run with that? I feel like this will break my shell scripts which use forward slashes everywhere.

It should be fine. Your scripts can still use forward slashes. The built-in tools, like basename and dirname, will work regardless of the type of slash. Just don't try parsing paths from variables by hand in your scripts without allowing for backslashes.

If you can give me an insight as to what should be fixed in choco I'll ticket it there.

It seems the only variable that has to contain backslashes for choco to work is CHOCOLATEYINSTALL.

Since it's set up that way by the installer I fully expect the choco developers to say it isn't their problem.

avih commented 1 year ago

Since it's set up that way by the installer I fully expect the choco developers to say it isn't their problem.

Not sure I follow.

Are you saying that CHOCOLATEYINSTALL must have backslashes to work correctly, but the choko framework sets it with forward slashes?

EDIT, oh, they set correctly hence not their problem, yes?

rmyorston commented 1 year ago

they set correctly hence not their problem, yes?

Yes.

doctorpangloss commented 1 year ago

What is the significance of seeing \\?\ at the beginning of paths? I see this in other places too. For example, node says it can't find a file that is indeed at the path it says, but the path it's looking up starts with \\?\. Will that all be resolved by sh -X?

doctorpangloss commented 1 year ago

anyway sh -ilX works well for me as the startup task in Windows Terminal, so I am closing this. thank you!