[Feature]: Native bzip2 decompression support for Windows hosts (#4819)
- Dominant language
- Go
- Stars
- 21.9k
- Forks
- 957
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 53
Description
## Description
This issue is a specialized sub-task of the broader Windows standalone initiative outlined in **#4819**. As discussed in [this comment](https://github.com/lima-vm/lima/issues/4819#issuecomment-4323356215), we are breaking down the major architectural changes into narrowly focused enhancements to ensure a more stable and reviewable implementation path.
As part of the initiative to eliminate external MSYS2/Cygwin dependencies, the mechanism for decompressing `.bz2` OS images needs to be refactored. Currently, `limactl` shells out to host-level binaries (like `bzip2` or `tar -xj`) to handle extraction. On a "plain" Windows installation without Git for Windows or MSYS2 in the system `%PATH%`, this dependency causes the image provisioning process to fail entirely.
---
## Steps to Reproduce (Current Limitation)
1. Provision a "plain" Windows machine with no POSIX toolchains installed.
2. Attempt to start a Lima instance using an image compressed with `bzip2` (e.g., standard `.tar.bz2` rootfs).
3. The extraction phase attempts to shell out to the host OS.
---
## Actual Behavior
The process halts because the host lacks the necessary external Unix toolchain to decompress the stream. The CLI throws an execution error indicating that the required executable file is not found in `%PATH%`.
---
## Expected Behavior
`limactl` should transparently and natively decompress `.bz2` image streams entirely within Go, allowing the image to be resolved and loaded correctly on Windows without requiring the user to manually install external POSIX workaround tools.
---
## Root Cause Analysis
Currently, the unpacking logic relies on `exec.Command` calls that assume a Unix-like environment is present to handle stream decompression before passing it to the file writer or tar extractor.
* External binaries introduce significant cross-platform friction.
* Shelling out breaks the goal of a 100% standalone `limactl.exe` on Windows.
---
## Suggested Fix
Introduce a native Go decompression layer interceptor that utilizes the standard library's `compress/bzip2` package. When a `.bz2` extension or magic number is detected, route the `io.Reader` through the native Go decompressor before writing.
```go
import "compress/bzip2"
// Proposed implementation strategy
func newBzip2Reader(r io.Reader) io.Reader {
return bzip2.NewReader(r)
}
```
## Environment
| Field | Value |
| :--- | :--- |
| **OS** | Windows 11 / Windows 10 (Standalone) |
| **Epic** | #4819 |
| **Go version** | 1.22+ |
| **Target Area** | Image decompression / unpacking logic |
---
## Note
I am actively researching the implementation for this and have a working local approach in mind. I am happy to open a PR with the native Go fix as soon as a maintainer confirms this approach is acceptable for #4819.
Contributor guide
Assessment
This issue has not been assessed yet.