A pipeline step `yq r values.yaml image.tag` fails with `Error: unknown command "r" for "yq"`, and on another runner `yq '.image.tag' values.yaml` fails with `yq: error: argument files: can't open '.image.tag'`.
IntermediateTroubleshootingTroubleshooting: tools, portability, permissions and environment
Answer
Likely causes → There are several incompatible tools named yq. mikefarah/yq v4 (Go) removed the v3 r/w subcommands in favour of expressions. The second error comes from the Python yq (a jq wrapper, installed via pip), which expects a jq filter and different argument handling.
Diagnose →
yq --version # "yq (https://github.com/mikefarah/yq/) version v4.44.x" vs "yq 3.x" (python)
command -v -a yq
Fix → Standardise on one: mikefarah v4 syntax is yq '.image.tag' values.yaml and yq -i '.image.tag = strenv(TAG)' values.yaml. Install a pinned binary in CI:
YQ_VERSION=v4.44.3
curl -fsSL -o /usr/local/bin/yq "https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64"
chmod +x /usr/local/bin/yq
Prevent → Pin tool versions in CI images and check at start-up: yq --version | grep -q 'mikefarah' || die "mikefarah yq v4 required".
More on Troubleshooting: tools, portability, permissions and environment
On a Mac, `sed -i 's/replicas: 2/replicas: 3/' deploy.yaml` fails with `sed: 1: "deploy.yaml": extra characters at the end of d command`.BeginnerA cleanup script fails on a developer's Mac with `date: illegal option -- d`.BeginnerA script that works on Ubuntu fails in an Alpine-based CI image with `grep: unrecognized option: P`.IntermediateAn `awk` one-liner works on your RHEL box but fails on Ubuntu with `awk: line 1: function gensub never defined`.Intermediate`comm -23 expected.txt installed.txt` prints `comm: file 1 is not in sorted order`, even though both files were produced with `sort`.Intermediate`grep ERROR /var/log/app/app.log` prints only `grep: /var/log/app/app.log: binary file matches`.Beginner