From f985b49ff8323c6ce05136c1d3cc9b5623a21326 Mon Sep 17 00:00:00 2001 From: liangshuo-1 <266696938+liangshuo-1@users.noreply.github.com> Date: Wed, 29 Apr 2026 20:10:02 +0800 Subject: [PATCH] chore(makefile): refuse `make install` in non-interactive mode `make install` builds from source and produces a binary that won't match official release artifacts (different version metadata, no codesigning, breaks the self-update flow). When AI assistants see "new version available" they tend to pattern-match to `make install` and silently clobber the user's properly-installed binary. Add a TTY gate so `make install`: - Refuses outright in non-interactive mode (AI Bash tool, CI, pipes) with a message pointing at `lark-cli update`. - Prompts y/N when run from a real terminal (contributor flow). - Honors `I_AM_A_CONTRIBUTOR=1` as an escape hatch for scripted contributor workflows. Also adds a banner comment at the top of the Makefile so anyone (including AI) reading the file sees the intended audience first. Change-Id: I17faf6ac34b571f7c59128a87e85ed19dd581e96 --- Makefile | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Makefile b/Makefile index 7d78c510b..dd58dd544 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,10 @@ # Copyright (c) 2026 Lark Technologies Pte. Ltd. # SPDX-License-Identifier: MIT +# +# END USERS / AI ASSISTANTS: To upgrade an existing lark-cli install, run +# `lark-cli update`. `make install` here is for CONTRIBUTORS building from +# source — it will NOT match official release artifacts and may break the +# self-update flow. BINARY := lark-cli MODULE := github.com/larksuite/cli @@ -28,6 +33,22 @@ integration-test: build test: vet unit-test integration-test install: build + @if [ -n "$$I_AM_A_CONTRIBUTOR" ]; then \ + : ; \ + elif [ -t 0 ] && [ -t 1 ]; then \ + echo "" ; \ + echo " make install builds from source — for CONTRIBUTORS only." ; \ + echo " To upgrade an existing lark-cli, run: lark-cli update" ; \ + echo "" ; \ + printf " Continue installing from source? (y/N) " ; \ + read ans ; \ + case "$$ans" in y|Y|yes|YES) ;; *) echo "Aborted." ; exit 1 ;; esac ; \ + else \ + echo "make install: refusing in non-interactive mode." ; \ + echo " To upgrade lark-cli: run \`lark-cli update\`." ; \ + echo " To install from source non-interactively: I_AM_A_CONTRIBUTOR=1 make install" ; \ + exit 1 ; \ + fi install -d $(PREFIX)/bin install -m755 $(BINARY) $(PREFIX)/bin/$(BINARY) @echo "OK: $(PREFIX)/bin/$(BINARY) ($(VERSION))"