Script Troubleshooting
Cheat sheet · https://pcornel.dk/topic.php?topic=5227
Answer
Script troubleshooting checks the input and how the script was called, the runtime and its version, the control flow, dependencies and external commands, and whether the target changed as expected — keeping logs and output before changing anything.
Remember
- Symptom ≠ root cause; a final error can be downstream of an earlier input, dependency or control-flow failure.
- Works interactively ≠ works in scheduler/service context; identity, environment, working directory and PATH can differ.
- Adding retries ≠ fixing the failure; retries can hide deterministic defects or duplicate side effects.
- Temporary script success ≠ durable fix; the original target outcome and adjacent regressions must be verified.
First checks
bash -x script.sh— trace executionSet-PSDebug -Trace 1— PowerShell tracepython3 -m pdb script.py— Python debugger
Commands
bash -n <script.sh>- Read-only/validation observation for Bash parser/syntax result without executing the script body.
Verify in this order
failure → reproduce → trace → fix → test
Where it usually breaks
A changed symptom or successful rerun proves only the observed path changed; root cause is not closed until the first failed boundary is explained and the original target outcome remains correct under regression checks.
Script/input → command/module binding → local/remoting session → request accepted → command result → target object read-back → effective runtime state → workload.
Script Troubleshooting scripting boundary map
| Boundary | Healthy evidence | Suspicious evidence |
|---|---|---|
| Input / runtime | Effective inputs, runtime, working context and dependency versions are explicit | Hidden defaults, stale environment, wrong interpreter/path or unvalidated input |
| Logic / execution | Branch/function/module decisions and external actions expose per-operation results | Swallowed failures, shell reinterpretation, blind retries or last-result-wins behavior |
| Result / proof | Exit/exception/log evidence is correlated with independent target read-back | Process success or printed output treated as target success |
| Recovery / troubleshooting | First failed boundary is preserved, changed minimally and retested | Random edits, catch-all suppression or evidence destroyed before diagnosis |
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5227