Skip to content

Commit 3c8ed54

Browse files
ausimianclaude
andcommitted
fix: stop the missing-tar warning claiming a verdict it cannot reach
It said the release "is never packed" and that "nothing can install this version", then acknowledged the counterexample in a trailing sentence without retracting either claim. All the check can see is one atom missing from the list as given; whether an archive appears is not visible to it, because a function step later in the list can pack one itself or add :tar to the steps still to run - %Mix.Release{} carries those remaining steps precisely so a step can. That combination is the worst available: a definite diagnosis on the error channel, sending an operator to investigate a packaging failure that may not exist, with the retraction buried after it. The warning now states the condition it observed and what follows unless something else packs the archive, and asserts nothing else. The test for it asserts the absence of both retracted claims as well as the presence of the conditional, so a message that dropped the consequence altogether fails too. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 4f2152e commit 3c8ed54

2 files changed

Lines changed: 42 additions & 8 deletions

File tree

lib/castle.ex

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,28 @@ defmodule Castle do
131131
# refuses, and `Forecastle.steps/1` hands such a list back untouched for that
132132
# refusal to happen. A second implementation of Mix's rule could only drift
133133
# from it.
134+
# **The warning states the condition it observed and a conditional
135+
# consequence, and asserts no verdict.** What this can see is one atom's
136+
# absence from the list as given. What it cannot see is whether an archive
137+
# appears anyway: a function step later in the list can pack one itself, or
138+
# add `:tar` to the steps still to run, and `%Mix.Release{}` carries those
139+
# remaining steps precisely so a step can. An earlier version of this said the
140+
# release "is never packed" and that "nothing can install this version" - then
141+
# acknowledged the counterexample in a trailing sentence without retracting
142+
# either claim, which is the worst of both: a definite diagnosis on the error
143+
# channel sending an operator to investigate a packaging failure that may not
144+
# exist. Say what was seen, say what follows *unless* something else packs it,
145+
# and stop.
134146
defp warn_missing_tar(steps) do
135147
if :assemble in steps and :tar not in steps do
136148
Mix.shell().error(
137-
"warning: Castle.customize/1 was given a :steps list with no :tar step, " <>
138-
"so this release is assembled but never packed into <name>-<vsn>.tar.gz. " <>
139-
"That tarball is what is copied into a deployment's releases directory " <>
140-
"for bin/castle unpack to read, so nothing can install this version onto " <>
141-
"a running system. Add :tar after :assemble if this version is meant to " <>
142-
"be installed anywhere. A deployment that is only ever upgraded from " <>
143-
"needs no tarball of its own, and a step of your own may be packing one, " <>
144-
"in which case there is nothing here to act on."
149+
"warning: Castle.customize/1 was given a :steps list with no :tar step. " <>
150+
"Unless a step of your own packs one, this release will not produce the " <>
151+
"<name>-<vsn>.tar.gz that is copied into a deployment's releases " <>
152+
"directory for bin/castle unpack to read - and bin/castle unpack is how " <>
153+
"a version is installed onto a running system. Add :tar after :assemble " <>
154+
"if this version is meant to be installed anywhere. A deployment that is " <>
155+
"only ever upgraded *from* needs no tarball of its own."
145156
)
146157
end
147158
end

test/castle/customize_test.exs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,29 @@ defmodule Castle.CustomizeTest do
101101
assert message =~ "bin/castle unpack"
102102
end
103103

104+
test "claims no verdict about whether an archive appears" do
105+
# All this can see is one atom missing from the list as given. A function
106+
# step later in the list can pack an archive itself, or add `:tar` to the
107+
# steps still to run - `%Mix.Release{}` carries those precisely so a step
108+
# can - so the absence of the atom is not the absence of a tarball.
109+
#
110+
# Asserted as the absence of the assertions, because that is the defect: an
111+
# earlier version said the release "is never packed" and that "nothing can
112+
# install this version", then acknowledged the counterexample in a trailing
113+
# sentence without retracting either. A definite diagnosis on the error
114+
# channel sends an operator after a packaging failure that may not exist.
115+
Castle.customize(steps: [:assemble])
116+
117+
assert_received {:mix_shell, :error, [message]}
118+
119+
refute message =~ "never packed"
120+
refute message =~ "nothing can install"
121+
122+
# And the conditional is present rather than merely the claims being gone,
123+
# so a message that dropped the consequence entirely fails too.
124+
assert message =~ "Unless a step of your own packs one"
125+
end
126+
104127
test "says nothing when the list has one" do
105128
Castle.customize(steps: [:assemble, :tar])
106129

0 commit comments

Comments
 (0)