{"record":{"id":"367adb59998124e6","repo":"GyulyVGC/sniffnet","slug":"command-failed-with-exit-code-error-returncode-error-cmd","errorCode":null,"errorMessage":"Command failed with exit code {error.returncode}: {error.cmd}","messagePattern":"Command failed with exit code (.+?): (.+?)","errorType":"exception","errorClass":"SystemExit","httpStatus":null,"severity":"error","filePath":"resources/packaging/linux/deb-source/prepare.py","lineNumber":161,"sourceCode":"    parser.add_argument(\"--output\", type=Path, default=ROOT / \"target/debian-source\")\n    parser.add_argument(\"--build-source\", action=\"store_true\",\n                        help=\"also run dpkg-buildpackage to create an unsigned source upload (Linux)\")\n    args = parser.parse_args()\n    if args.build_source and not shutil.which(\"dpkg-buildpackage\"):\n        parser.error(\"--build-source requires dpkg-buildpackage and debhelper\")\n    source = prepare(args.output.resolve())\n    if args.build_source:\n        # Build-Depends are needed for the binary build, not source assembly.\n        run(\"dpkg-buildpackage\", \"-S\", \"-sa\", \"-us\", \"-uc\", \"-d\", cwd=source)\n\n\nif __name__ == \"__main__\":\n    try:\n        main()\n    except subprocess.CalledProcessError as error:\n        if error.stderr:\n            print(error.stderr, file=sys.stderr)\n        raise SystemExit(f\"Command failed with exit code {error.returncode}: {error.cmd}\") from error\n","sourceCodeStart":143,"sourceCodeEnd":162,"githubUrl":"https://github.com/GyulyVGC/sniffnet/blob/592a62a5ad2fb2e9f8470a6174ab9f18dc86997a/resources/packaging/linux/deb-source/prepare.py#L143-L162","documentation":"The __main__ block catches subprocess.CalledProcessError raised by the run() helper (which uses check=True) and re-raises it as SystemExit with the failing command and its exit code. Any external command the script shells out to (git, tar, cargo, dpkg-buildpackage) that exits non-zero produces this message; the command's stderr, if captured, is printed first.","triggerScenarios":"git rev-parse --verify on a missing tag (refs/tags/vX.Y.Z does not exist); git show on an invalid commit; tar failing to extract the archive; cargo vendor/metadata failing (bad lockfile, missing vendored deps, offline config issues); dpkg-buildpackage failing during --build-source.","commonSituations":"Running the script on a checkout without the release tag fetched (git fetch --tags); Cargo.lock out of sync with Cargo.toml in the tagged commit; cargo/rust toolchain too old for the project's rust-version; building on a machine missing dpkg-buildpackage/debhelper; network fetch attempts blocked by the forced offline vendored config.","solutions":["Read the stderr printed above the message to identify the failing command and its cause","If git rev-parse failed: fetch tags with git fetch --tags and confirm the tag exists (git tag -l 'v*')","If cargo vendor/metadata failed: verify Cargo.lock matches Cargo.toml at the tagged commit and use a Rust toolchain meeting rust-version (rustup update)","If dpkg-buildpackage failed: install dpkg-dev and debhelper (sudo apt install dpkg-dev debhelper) and inspect debian/rules for missing build-deps"],"exampleFix":"// before\npython3 prepare.py --build-source\n# stderr: fatal: ambiguous argument 'refs/tags/v1.3.1^{commit}'\n// after\ngit fetch --tags origin\npython3 prepare.py --build-source","handlingStrategy":"try-catch","validationCode":"# pre-flight checks before running the packager\ngit rev-parse --verify refs/tags/v1.3.1^{commit} || { git fetch --tags; }\ncargo --version\ntar --version\ndpkg-buildpackage --version  # only if --build-source will be used","typeGuard":null,"tryCatchPattern":"import subprocess\ntry:\n    prepare(output)\nexcept subprocess.CalledProcessError as error:\n    if error.stderr:\n        print(error.stderr, file=sys.stderr)\n    print(f\"Command failed with exit code {error.returncode}: {error.cmd}\", file=sys.stderr)\n    sys.exit(error.returncode)","preventionTips":["Fetch all tags (git fetch --tags) before packaging a release","Ensure the Rust toolchain satisfies the project's rust-version","Install required system tools: git, tar, cargo, and dpkg-buildpackage/debhelper for --build-source","Read the stderr emitted above this message — it names the exact failing command and underlying cause","Validate Cargo.lock is committed and consistent with Cargo.toml at the tagged commit"],"tags":["subprocess","git","external-command","exit-code"],"backgroundTag":"git-command-failed","analyzedSha":"592a62a5ad2fb2e9f8470a6174ab9f18dc86997a","analyzedAt":"2026-09-18T11:20:14.290Z","contentChangedAt":"2026-09-18T11:20:14.290Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}