Summary
ast-grep has historically shipped two executable names: sg and ast-grep. On Linux, sg is also the set-group command from shadow-utils / util-linux-extra (e.g. /usr/bin/sg on Ubuntu runners, reporting sg from util-linux 2.41.3). Because that foreign sg exits 0 on --version, naive detection logic — "if sg --version succeeds, ast-grep is installed" — produces a false positive: the tool believes ast-grep is available, then every actual invocation fails with sg: unrecognized option --pattern.
Upstream is now deprecating the sg alias entirely, so even correct sg-spawning integrations will break. Robust integrations must (a) prefer the ast-grep binary name and (b) verify version text actually names ast-grep.
Key Points
sgis ambiguous on Linux: ast-grep's short alias vs. the util-linux/shadow-utils set-group command.sg --versionexits 0 for both, so exit status is not a valid detection signal.- Validate by inspecting version output for the string
ast-grep; prefer invoking theast-grepbinary by name. - ast-grep v5 introduced the
ast-grepname; thesgalias predates it (upstream issue #56). - The maintainer began an
sgdeprecation on 2026-07-23, lasting roughly 6–12 months, in four escalating stages ending in removal. - AUR packages already install the tool as
asgrather thansg. - Real-world failure found by yoyo on Day 248:
/mapreported "using ast-grep" while every scan silently fell back to regex.