Skip to content

writ never detects the Linux distribution: detectDistro closes /etc/os-release before reading it, so no .Debian or .Ubuntu directory deploys anywhere #959

Closed

Description

@David-Noble-at-work

cmd/writ/writ/segment/detect.go, detectDistro: iox.Close(&err, file) runs directly — not deferred — between os.Open and bufio.NewScanner(file), so the scan reads a closed file (read /etc/os-release: file already closed) and the function returns "". The DISTRO segment is always empty; segmentMap drops it; no directory with a distribution suffix has matched on any Linux host since the line landed in 57a9fd2 (#288, 2026-07-24).

Found 2026-09-26 by an independent verification of a deploy on DANOBLE-UD24-1 (Ubuntu 26.04): /etc/os-release carries ID=ubuntu, and every writ graph in ~/.local/state/devlore/index.ndjson back to 2026-09-18 records segments {ARCH: arm64, OS: Linux} with no DISTRO. A replica of the function that copies iox.Close verbatim prints the closed-file error and returns "". segment_test.go builds DISTRO values by hand and never calls detectDistro, which is why nothing caught it.

So Home/common.Debian (personal's Upgrade-Debian, #224) deploys nowhere, Debian included, and #860/#944's reasoning about which distribution suffix matches was never exercised. The fix: defer iox.Close(&err, file) with err in scope; a test that calls detectDistro against an os-release fixture. The selector grammar itself is #944's.

Plan and design documents

Kind Document
Plan docs/plans/fix/959-writ-never-detects-the-linux.md

Epic: #447 · Feature: #463

Activity

  1. David-Noble-at-work commented on Sep 28, 2026

    @David-Noble-at-work
    ContributorAuthor

    A test pins this bug (found 2026-09-28). cmd/writ/writ/adopt/adopt_integration_test.go:341-343 asserts that ValidatePlatform("Ubuntu") is refused as "a word the layer tree never matches". It runs in the normal unit suite, with no build tag. It passes on Ubuntu, and on every Linux CI leg (all Ubuntu: .github/workflows/ci.yaml:162-163, :213-214), only because DISTRO is empty. The fix for detect.go:130 makes it fail there, so the fix corrects that test in the same commit. Also, TestDetectSegments never checks DISTRO on Linux (cmd/writ/writ/segment/segment_test.go:214-231), which is how the regression from 57a9fd20 passed. Details are on #944.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Epic:WritDeploymentwrit deployment: layers, adoption, and driftbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions