RubyMetric / rbenv-for-windows

rbenv for Windows - Manage your app's Ruby environment on Windows
MIT License
122 stars 13 forks source link

Failed to extract files from \cache\rubyinstaller, 7zip, decompress error #24

Open vladyslav-androshchuk opened 9 months ago

vladyslav-androshchuk commented 9 months ago

Hello!

During the execution of rbenv install 3.1.0 on Windows 10 in PowerShell, I'm getting the following error:

C:\Ruby\rbenv\bin\rbenv install 3.1.0
Begin downloading ...
=> https://github.com/oneclick/rubyinstaller2/releases/download/RubyInstaller-3.1.0-1/rubyinstaller-3.1.0-1-x64.7z
Loading rubyinstaller-3.1.0-1-x64.7z from cache
Installing 3.1.0-1 ...
Exit code was 7!
Failed to extract files from \cache\rubyinstaller-3.1.0-1-x64.7z.
Log file:
  \cache\7zip.log
 'decompress error')

\cache\7zip.log:

Command Line Error:
Too short switch:
-o

7zip v23.1.0 was installed using Chocolatey.

ccmywish commented 9 months ago

Hi @vladyslav-androshchuk

Thanks for reporting. I find that, the 7zip version v23.1.0 from Chocolatey is strange, because I don't find that version from a quick look at https://www.7-zip.org/download.html

I download the latest 24.01 beta (2024-01-31), find that -o option is still working.

7-Zip (a) 24.01 (x64) : Copyright (c) 1999-2024 Igor Pavlov : 2024-01-31

Usage: 7za <command> [<switches>...] <archive_name> [<file_names>...] [@listfile]

<Commands>
  a : Add files to archive
  b : Benchmark
  d : Delete files from archive
  e : Extract files from archive (without using directory names)
  h : Calculate hash values for files
  i : Show information about supported formats
  l : List contents of archive
  rn : Rename files in archive
  t : Test integrity of archive
  u : Update files to archive
  x : eXtract files with full paths

<Switches>
  -- : Stop switches and @listfile parsing
  -ai[r[-|0]][m[-|2]][w[-]]{@listfile|!wildcard} : Include archives
  -ax[r[-|0]][m[-|2]][w[-]]{@listfile|!wildcard} : eXclude archives
  -ao{a|s|t|u} : set Overwrite mode
  -an : disable archive_name field
  -bb[0-3] : set output log level
  -bd : disable progress indicator
  -bs{o|e|p}{0|1|2} : set output stream for output/error/progress line
  -bt : show execution time statistics
  -i[r[-|0]][m[-|2]][w[-]]{@listfile|!wildcard} : Include filenames
  -m{Parameters} : set compression Method
    -mmt[N] : set number of CPU threads
    -mx[N] : set compression level: -mx1 (fastest) ... -mx9 (ultra)
  -o{Directory} : set Output directory

So, I suggest you can try install 7zip by scoop or just manually install another version and save it into the PATH.

ccmywish commented 9 months ago

And the decompression logic is written here for check.

https://github.com/ccmywish/rbenv-for-windows/blob/e795a4710a93eb2e10a1198361aa33313868000c/lib/decompress.ps1#L34

vladyslav-androshchuk commented 9 months ago

Hi @vladyslav-androshchuk

Thanks for reporting. I find that, the 7zip version v23.1.0 from Chocolatey is strange, because I don't find that version from a quick look at https://www.7-zip.org/download.html

I download the latest 24.01 beta (2024-01-31), find that -o option is still working.

7-Zip (a) 24.01 (x64) : Copyright (c) 1999-2024 Igor Pavlov : 2024-01-31

Usage: 7za <command> [<switches>...] <archive_name> [<file_names>...] [@listfile]

<Commands>
  a : Add files to archive
  b : Benchmark
  d : Delete files from archive
  e : Extract files from archive (without using directory names)
  h : Calculate hash values for files
  i : Show information about supported formats
  l : List contents of archive
  rn : Rename files in archive
  t : Test integrity of archive
  u : Update files to archive
  x : eXtract files with full paths

<Switches>
  -- : Stop switches and @listfile parsing
  -ai[r[-|0]][m[-|2]][w[-]]{@listfile|!wildcard} : Include archives
  -ax[r[-|0]][m[-|2]][w[-]]{@listfile|!wildcard} : eXclude archives
  -ao{a|s|t|u} : set Overwrite mode
  -an : disable archive_name field
  -bb[0-3] : set output log level
  -bd : disable progress indicator
  -bs{o|e|p}{0|1|2} : set output stream for output/error/progress line
  -bt : show execution time statistics
  -i[r[-|0]][m[-|2]][w[-]]{@listfile|!wildcard} : Include filenames
  -m{Parameters} : set compression Method
    -mmt[N] : set number of CPU threads
    -mx[N] : set compression level: -mx1 (fastest) ... -mx9 (ultra)
  -o{Directory} : set Output directory

So, I suggest you can try install 7zip by scoop or just manually install another version and save it into the PATH.

Hey! Somehow it's extremely hard to install 7zip today, any version from Choco doesn't work. Scoop can't install it, because the install URL is not accessible, as well as links from official sites. Maybe we can use other options for decompression, without 3d parties?

Also, we are using puppet to setup our machines, so only automation.

Thanks for your time.

ccmywish commented 9 months ago

@vladyslav-androshchuk

Temporarily it's not possible to decompress without 7z.

Based on your comments any version from Choco doesn't work, I doubt it's may not because of 7zip.

You can insert a debug line like Write-Host $7zPath $ArgList -LogPath $LogPath before:

https://github.com/ccmywish/rbenv-for-windows/blob/main/lib/decompress.ps1#L47

to check what went wrong.

Just a guess: I guess maybe it's your path includes a space or other characters that cause the error.