From 0ba58d92780bec61af65e51e9152b570f0d8cc64 Mon Sep 17 00:00:00 2001 From: Zoltan Csizmadia Date: Sun, 25 Oct 2026 10:53:18 -0500 Subject: [PATCH 1/2] compact: run fstrim by its path; WSL 3.0's --exec does not find /sbin tools (#560) --- internal/compact/compact.go | 4 +++- internal/compact/compact_test.go | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/internal/compact/compact.go b/internal/compact/compact.go index 4512875..67e868c 100644 --- a/internal/compact/compact.go +++ b/internal/compact/compact.go @@ -195,7 +195,9 @@ func (r *Runner) Run(ctx context.Context, opts Options) (Report, error) { // 1. Trim: the guest tells the disk what it no longer uses. Without this, // compaction has nothing to reclaim. if !opts.NoTrim { - out, err := r.WSL.Exec(ctx, opts.Distro, "root", "fstrim", "-v", "/") + // By path: WSL 3.0's `wsl --exec` does not find /sbin tools by name + // (#560). The rootfs is ours, so the path is fixed. + out, err := r.WSL.Exec(ctx, opts.Distro, "root", "/sbin/fstrim", "-v", "/") if err != nil { return rep, fmt.Errorf("compact: fstrim in %s: %w: %s", opts.Distro, err, strings.TrimSpace(out)) } diff --git a/internal/compact/compact_test.go b/internal/compact/compact_test.go index c0f0cde..5acab0f 100644 --- a/internal/compact/compact_test.go +++ b/internal/compact/compact_test.go @@ -23,6 +23,11 @@ type fakeWSL struct { func (f *fakeWSL) Exec(_ context.Context, distro, user string, args ...string) (string, error) { f.calls = append(f.calls, "exec:"+distro+":"+strings.Join(args, " ")) + // WSL 3.0's relay does not search /sbin for `wsl --exec`, though /sbin is + // on the PATH the process gets (#560). + if args[0] == "fstrim" { + return "execvpe(fstrim) failed: No such file or directory", errors.New("exit status 1") + } return f.fstrimOut, f.fstrimErr } @@ -94,7 +99,7 @@ func TestHappyPathOrdersTrimStopTerminateCompact(t *testing.T) { if !started { t.Error("--restart did not start the engine again") } - if got := strings.Join(w.calls, "|"); !strings.Contains(got, "exec:skrog-engine:fstrim -v /") || + if got := strings.Join(w.calls, "|"); !strings.Contains(got, "exec:skrog-engine:/sbin/fstrim -v /") || !strings.Contains(got, "terminate:skrog-engine") { t.Errorf("calls = %s", got) } From 696a05f286a9ba890fe4a4c015f84dab051564b9 Mon Sep 17 00:00:00 2001 From: Zoltan Csizmadia Date: Sun, 25 Oct 2026 11:00:02 -0500 Subject: [PATCH 2/2] changelog: compact fstrim on WSL 3.0 (#560) --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac0ef36..7feaca1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ useful than saying where the real one is. ### Fixed +- **`skrog compact` no longer fails at `fstrim` on WSL 3.0** ([#560](https://github.com/wslkit/skrog/issues/560)). + WSL 3.0's `wsl --exec` does not find tools in `/sbin` by name, so the first step failed + with `execvpe(fstrim) failed`. It now runs `/sbin/fstrim`. On WSL 3.0.3 compaction still + fails at the next step, because the disk is not released; #560 tracks that. - **`wsl.auto-memory-reclaim` now takes effect** ([#550](https://github.com/wslkit/skrog/issues/550)). `skrog wsl-config apply` wrote `autoMemoryReclaim` under `[wsl2]`, but WSL reads it only as `experimental.autoMemoryReclaim`: it ignored the line and printed `Unknown key